static void Main(string[] args) { var test = new InstantiationTest(); Console.WriteLine("Press key to start tests"); Console.ReadKey(); var res = test.Measure(); Console.WriteLine("MethodA: " + res.Item1 + "ms"); Console.WriteLine("MethodB: " + res.Item2 + "ms"); Console.WriteLine("MethodC: " + res.Item3 + "ms"); Console.ReadKey(); }
private void RunTest(TestType testType, bool RunBaseLine = true) { PerformanceTest test = null; int iterations = int.Parse(inputField.text); switch (testType) { case TestType.Exception: test = new ExceptionTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Strings: test = new StringsTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Arrays: test = new ArraysTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Boxing: test = new BoxingTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.ForForeach: test = new ForForeachTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Struct: test = new StructTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Memory: test = new MemoryTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Instantiation: test = new InstantiationTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; case TestType.Properties: test = new PropertiesTest { RunBaseline = RunBaseLine, Iterations = iterations }; break; default: throw new ArgumentOutOfRangeException(nameof(testType), testType, null); } titleText.text = test.Name; descriptionText.text = test.Description; var averageResult = test.Measure(); lastPerformanceResult = averageResult; UpdatePerformanceResultUI(); var(perA, perB, perC) = GetPercentageOfResult(averageResult); totalASlider.value = perA; totalBSlider.value = perB; totalCSlider.value = perC; }