summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-05-03 07:49:30 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-05-03 07:49:30 -0700
commit8b17677ac0934a04b0a1547b06e178d3171a41b4 (patch)
treed3b410d7aa07dcc529f54e163bc0d6d0ec95ff49 /src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs
parentb8690062e9ededc3c5d15d246f77ced834b11193 (diff)
downloadDotNetOpenAuth-8b17677ac0934a04b0a1547b06e178d3171a41b4.zip
DotNetOpenAuth-8b17677ac0934a04b0a1547b06e178d3171a41b4.tar.gz
DotNetOpenAuth-8b17677ac0934a04b0a1547b06e178d3171a41b4.tar.bz2
Moved the performance measuring method into TestBase.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs b/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs
index 1b747aa..5e28732 100644
--- a/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs
+++ b/src/DotNetOpenAuth.Test/Performance/PerformanceTestUtilities.cs
@@ -13,44 +13,16 @@ namespace DotNetOpenAuth.Test.Performance {
using NUnit.Framework;
internal static class PerformanceTestUtilities {
- private static Stats baseline;
+ internal static Stats Baseline;
static PerformanceTestUtilities() {
- baseline = CollectBaseline();
+ Baseline = CollectBaseline();
TestUtilities.TestLogger.InfoFormat(
"Scaled where EmptyStaticFunction = 1.0 ({0:f1} nsec = 1.0 units)",
- baseline.Median * 1000);
+ Baseline.Median * 1000);
}
- internal static Stats Measure(Action action, float maximumAllowedUnitTime, int samples = 10, int iterations = 100, string name = null) {
- if (!IsOptimized(typeof(OpenIdRelyingParty).Assembly)) {
- Assert.Inconclusive("Unoptimized code.");
- }
-
- var timer = new MultiSampleCodeTimer(samples, iterations);
- Stats stats;
- using (new HighPerformance()) {
- stats = timer.Measure(name ?? TestContext.CurrentContext.Test.FullName, action);
- }
-
- stats.AdjustForScale(PerformanceTestUtilities.baseline.Median);
-
- TestUtilities.TestLogger.InfoFormat(
- "Performance counters: median {0}, mean {1}, min {2}, max {3}, stddev {4} ({5}%).",
- stats.Median,
- stats.Mean,
- stats.Minimum,
- stats.Maximum,
- stats.StandardDeviation,
- stats.StandardDeviation / stats.Median * 100);
-
- Assert.IsTrue(stats.Mean < maximumAllowedUnitTime, "The mean time of {0} exceeded the maximum allowable of {1}.", stats.Mean, maximumAllowedUnitTime);
- TestUtilities.TestLogger.InfoFormat("Within {0}% of the maximum allowed time of {1}.", Math.Round((maximumAllowedUnitTime - stats.Mean) / maximumAllowedUnitTime * 100, 1), maximumAllowedUnitTime);
-
- return stats;
- }
-
- private static bool IsOptimized(Assembly assembly) {
+ internal static bool IsOptimized(Assembly assembly) {
DebuggableAttribute debugAttribute = (DebuggableAttribute)System.Attribute.GetCustomAttribute(assembly, typeof(System.Diagnostics.DebuggableAttribute));
return debugAttribute == null || !debugAttribute.IsJITOptimizerDisabled;
}