/// <summary> /// Compare times of addition of int, int?s and SmartInt /// </summary> public static void OperationsAdd() { MemPerfStatus mps_Int = new MemPerfStatus(true); MemPerfStatus mps_IntN = new MemPerfStatus(true); MemPerfStatus mps_SmartInt = new MemPerfStatus(true); SmartIntBM_SimpleOperations tt = new SmartIntBM_SimpleOperations(); // Warmup tt.Additions_Int(); mps_Int.Start(); for (var i = 0; i < 10; i++) { tt.Additions_Int(); } mps_Int.Stop(); // Warmup tt.Additions_IntN(); mps_IntN.Start(); for (var i = 0; i < 10; i++) { tt.Additions_IntN(); } mps_IntN.Stop(); // Warmup tt.Additions_SmartInt(); mps_SmartInt.Start(); for (var i = 0; i < 10; i++) { tt.Additions_SmartInt(); } mps_SmartInt.Stop(); mps_Int.Report("Int "); mps_Int.Report("Int? "); mps_SmartInt.Report("SmartInt"); }
public static void RunTest(string[] args) { // Default number of generated figures int figures_count = 100000; // Number of vertexes in each figure int points_count = 5; // Try to get number of generated figures from command line arguments if (args.Length > 0) { figures_count = int.Parse(args[0]); } // Allocate memory for test data PointF[][] figures_p = new PointF[figures_count][]; string[] figures_s = new string[figures_count]; char[][] figures_sa = new char[figures_count][]; // Initialise test data for (int i = 0; i < figures_count; i++) { figures_p[i] = new PointF[points_count]; figures_s[i] = ToString(GenerateRandom(points_count)); figures_sa[i] = figures_s[i].ToCharArray(); } // Initialise counters MemPerfStatus mps_Classic = new MemPerfStatus(true); MemPerfStatus mps_Substring = new MemPerfStatus(true); MemPerfStatus mps_SmartDouble = new MemPerfStatus(true); // Warming up Parse_Classic(figures_s[0], figures_p[0]); Parse_Substring(figures_s[0], figures_p[0]); Parse_SmartDouble(figures_s[0], figures_p[0]); // Testing Parse_Classic mps_Classic.Start(); for (int i = 0; i < figures_count; i++) { Parse_Classic(figures_s[i], figures_p[i]); } mps_Classic.Stop(); // Testing Parse_Substring mps_Substring.Start(); for (int i = 0; i < figures_count; i++) { Parse_Substring(figures_s[i], figures_p[i]); } mps_Substring.Stop(); // Testing Parse_SmartDouble mps_SmartDouble.Start(); for (int i = 0; i < figures_count; i++) { Parse_SmartDouble(figures_s[i], figures_p[i]); } mps_SmartDouble.Stop(); // Reporting - Garbage Collection Count, Memory Usage, Time period Console.WriteLine("Figures:{0}", figures_count); Console.WriteLine("Points:{0}", points_count); mps_Classic.Report("Classic "); mps_Substring.Report("Substring "); mps_SmartDouble.Report("SmartDouble"); // Console.ReadKey(); }