static void Main(string[] args) { System.Console.WriteLine("Initializing 10^7 boxes randomly lying between (0,0) and (2,2).\n"); BBox[] arr = BBox.getBBArray(10000000); for (int j = 3; j < 8; j++) { int n = (int)Math.Pow(10, j); System.Console.WriteLine("For 10^{0} elements: \n", j); //Calculate using native c# System.Console.WriteLine("Calculating with C# [10 iterations]:"); float perc = 0; double time = 0; for (int i = 0; i < 10; i++) { var s1 = Stopwatch.StartNew(); perc = BBox.getPercentBB(arr, n); s1.Stop(); time += s1.Elapsed.TotalMilliseconds; } System.Console.WriteLine("The Percentage of boxes that lie between (0,0) and (1,1) are : {0}%.", perc); System.Console.WriteLine("The Calculation took: {0} milliseconds. \n", time / 10); //Interop with Marshaling System.Console.WriteLine("Calculating with Marshaling Interop [10 iterations]:"); time = 0; for (int i = 0; i < 10; i++) { var s3 = Stopwatch.StartNew(); perc = BBox.getPercentBBMarshal(arr, n); s3.Stop(); time += s3.Elapsed.TotalMilliseconds; } System.Console.WriteLine("The Percentage of boxes that lie between (0,0) and (1,1) are : {0}%.", perc); System.Console.WriteLine("The Calculation took: {0} milliseconds. \n", time / 10); //Interop with raw pointers System.Console.WriteLine("Calculating with Pointer Interop [10 iterations]:"); time = 0; for (int i = 0; i < 10; i++) { var s2 = Stopwatch.StartNew(); perc = BBox.getPercentBBInterop(arr, n); s2.Stop(); time += s2.Elapsed.TotalMilliseconds; } System.Console.WriteLine("The Percentage of boxes that lie between (0,0) and (1,1) are : {0}%.", perc); System.Console.WriteLine("The Calculation took: {0} milliseconds. \n", time / 10); } }