Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Main(string[] args)
- {
- const int globalRuns = 10;
- const int localRuns = 1000;
- var source = Enumerable.Range(1, 200000).OrderBy(n => Guid.NewGuid()).ToArray();
- var a = new int[source.Length];
- int start, end, total;
- for (int z = 0; z < globalRuns; z++)
- {
- Console.WriteLine("Run #{0}", z+1);
- total = 0;
- for (int i = 0; i < localRuns; i++)
- {
- Array.Copy(source, a, source.Length);
- start = Environment.TickCount;
- Array.Sort(a);
- end = Environment.TickCount;
- total += end - start;
- }
- Console.WriteLine("{0}\t\tTtl: {1}ms\tAvg: {2}ms", ".NET", total, total / localRuns);
- total = 0;
- for (int i = 0; i < localRuns; i++)
- {
- Array.Copy(source, a, source.Length);
- start = Environment.TickCount;
- Quicksort.Sort(a);
- end = Environment.TickCount;
- total += end - start;
- }
- Console.WriteLine("{0}\t\tTtl: {1}ms\tAvg: {2}ms", "Inlined", total, total / localRuns);
- total = 0;
- for (int i = 0; i < localRuns; i++)
- {
- Array.Copy(source, a, source.Length);
- start = Environment.TickCount;
- Quicksort.Sort2(a);
- end = Environment.TickCount;
- total += end - start;
- }
- Console.WriteLine("{0}\tTtl: {1}ms\tAvg: {2}ms\n", "Not inlined", total, total / localRuns);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement