diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-05-06 22:24:50 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-05-06 22:24:50 -0700 |
commit | d7e07694026888ae40254ee8468e40afe0ffee56 (patch) | |
tree | a10fdfb539b8481eea7d3400e70b85c6e8d6aa43 /src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs | |
parent | 0d17e6bbbd119520269716fb5de7db36a1a28683 (diff) | |
parent | 031ef0e5f8111bc5e1c157b8159d2b9e28b4eda3 (diff) | |
download | DotNetOpenAuth-d7e07694026888ae40254ee8468e40afe0ffee56.zip DotNetOpenAuth-d7e07694026888ae40254ee8468e40afe0ffee56.tar.gz DotNetOpenAuth-d7e07694026888ae40254ee8468e40afe0ffee56.tar.bz2 |
Merge branch 'v3.4' into oauth2
Conflicts:
samples/OAuthServiceProvider/Code/Global.cs
src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
src/DotNetOpenAuth/DotNetOpenAuth.csproj
src/DotNetOpenAuth/Messaging/Channel.cs
src/version.txt
Diffstat (limited to 'src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs b/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs new file mode 100644 index 0000000..5e28732 --- /dev/null +++ b/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------- +// <copyright file="PerformanceTestUtilities.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test.Performance { + using System; + using System.Diagnostics; + using System.Reflection; + using System.Threading; + using DotNetOpenAuth.OpenId.RelyingParty; + using NUnit.Framework; + + internal static class PerformanceTestUtilities { + internal static Stats Baseline; + + static PerformanceTestUtilities() { + Baseline = CollectBaseline(); + TestUtilities.TestLogger.InfoFormat( + "Scaled where EmptyStaticFunction = 1.0 ({0:f1} nsec = 1.0 units)", + Baseline.Median * 1000); + } + + internal static bool IsOptimized(Assembly assembly) { + DebuggableAttribute debugAttribute = (DebuggableAttribute)System.Attribute.GetCustomAttribute(assembly, typeof(System.Diagnostics.DebuggableAttribute)); + return debugAttribute == null || !debugAttribute.IsJITOptimizerDisabled; + } + + private static Stats CollectBaseline() { + using (new HighPerformance()) { + return new MultiSampleCodeTimer(10, 1000).Measure( + "MethodCalls: EmptyStaticFunction()", + 10, + delegate { + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + Class.EmptyStaticFunction(); + }); + } + } + + private class Class { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + public static void EmptyStaticFunction() { + } + } + } +} |