diff options
author | csharptest <roger@csharptest.net> | 2011-06-08 20:13:29 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-08 20:13:29 -0500 |
commit | 920b09a3b0af58440ed936183d5dfd5342eae1a0 (patch) | |
tree | 12bd44e1f596eacc05cc871ba30cc10114ae5868 /src/ProtoBench | |
parent | aef072a46f7c902e6fa1adf18e34f8d4b1eba38a (diff) | |
download | protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.tar.gz protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.tar.bz2 protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.zip |
Finished adding find tag by name
Diffstat (limited to 'src/ProtoBench')
-rw-r--r-- | src/ProtoBench/Program.cs | 84 |
1 files changed, 37 insertions, 47 deletions
diff --git a/src/ProtoBench/Program.cs b/src/ProtoBench/Program.cs index 36f7850d..2be2bf4f 100644 --- a/src/ProtoBench/Program.cs +++ b/src/ProtoBench/Program.cs @@ -58,6 +58,7 @@ namespace Google.ProtocolBuffers.ProtoBench private static BenchmarkTest RunBenchmark;
+ [STAThread]
public static int Main(string[] args)
{
List<string> temp = new List<string>(args);
@@ -160,58 +161,47 @@ namespace Google.ProtocolBuffers.ProtoBench long totalCount = 0;
double best = double.MinValue, worst = double.MaxValue;
- ThreadStart threadProc =
- delegate()
- {
- action();
- // Run it progressively more times until we've got a reasonable sample
-
- int iterations = 100;
- elapsed = TimeAction(action, iterations);
- while (elapsed.TotalMilliseconds < 1000)
- {
- elapsed += TimeAction(action, iterations);
- iterations *= 2;
- }
-
- TimeSpan target = TimeSpan.FromSeconds(1);
-
- elapsed = TimeAction(action, iterations);
- iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
- elapsed = TimeAction(action, iterations);
- iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
- elapsed = TimeAction(action, iterations);
- iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
+ action();
+ // Run it progressively more times until we've got a reasonable sample
- double first = (iterations * dataSize) / (elapsed.TotalSeconds * 1024 * 1024);
- if (Verbose) Console.WriteLine("Round ---: Count = {1,6}, Bps = {2,8:f3}", 0, iterations, first);
- elapsed = TimeSpan.Zero;
- int max = FastTest ? 10 : 30;
+ int iterations = 100;
+ elapsed = TimeAction(action, iterations);
+ while (elapsed.TotalMilliseconds < 1000)
+ {
+ elapsed += TimeAction(action, iterations);
+ iterations *= 2;
+ }
- while (runs < max)
- {
- TimeSpan cycle = TimeAction(action, iterations);
- // Accumulate and scale for next cycle.
-
- double bps = (iterations * dataSize) / (cycle.TotalSeconds * 1024 * 1024);
- if (Verbose) Console.WriteLine("Round {0,3}: Count = {1,6}, Bps = {2,8:f3}", runs, iterations, bps);
+ TimeSpan target = TimeSpan.FromSeconds(1);
- best = Math.Max(best, bps);
- worst = Math.Min(worst, bps);
+ elapsed = TimeAction(action, iterations);
+ iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
+ elapsed = TimeAction(action, iterations);
+ iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
+ elapsed = TimeAction(action, iterations);
+ iterations = (int)((target.Ticks * iterations) / (double)elapsed.Ticks);
- runs++;
- elapsed += cycle;
- totalCount += iterations;
- iterations = (int) ((target.Ticks*totalCount)/(double) elapsed.Ticks);
- }
- };
+ double first = (iterations * dataSize) / (elapsed.TotalSeconds * 1024 * 1024);
+ if (Verbose) Console.WriteLine("Round ---: Count = {1,6}, Bps = {2,8:f3}", 0, iterations, first);
+ elapsed = TimeSpan.Zero;
+ int max = FastTest ? 10 : 30;
- Thread work = new Thread(threadProc);
- work.Name = "Worker";
- work.Priority = ThreadPriority.Highest;
- work.SetApartmentState(ApartmentState.STA);
- work.Start();
- work.Join();
+ while (runs < max)
+ {
+ TimeSpan cycle = TimeAction(action, iterations);
+ // Accumulate and scale for next cycle.
+
+ double bps = (iterations * dataSize) / (cycle.TotalSeconds * 1024 * 1024);
+ if (Verbose) Console.WriteLine("Round {0,3}: Count = {1,6}, Bps = {2,8:f3}", runs, iterations, bps);
+
+ best = Math.Max(best, bps);
+ worst = Math.Min(worst, bps);
+
+ runs++;
+ elapsed += cycle;
+ totalCount += iterations;
+ iterations = (int) ((target.Ticks*totalCount)/(double) elapsed.Ticks);
+ }
Console.WriteLine("{0}: averages {1} per {2:f3}s for {3} runs; avg: {4:f3}mbps; best: {5:f3}mbps; worst: {6:f3}mbps",
name, totalCount / runs, elapsed.TotalSeconds / runs, runs,
|