From 9680b5262c1ce6749bb93a5c9aa631d5b86b6db9 Mon Sep 17 00:00:00 2001 From: Balaji Soundrarajan Date: Thu, 21 Apr 2016 09:25:18 -0700 Subject: [PATCH] This change enables the test csx files to provide the scenarios that needs to be monitored within a test execution This enables multiple scenarios cases as well --- src/Test/Perf/runner.csx | 21 +++++++++++++------ .../Perf/tests/csharp/csharp_compiler.csx | 5 +++++ .../Perf/tests/helloworld/hello_world.csx | 5 +++++ .../Perf/util/scenario_generator_util.csx | 7 ++++++- src/Test/Perf/util/test_util.csx | 2 ++ src/Test/Perf/util/trace_manager_util.csx | 13 ++++++++++++ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/Test/Perf/runner.csx b/src/Test/Perf/runner.csx index 912e721a7104c..a5e133aafe773 100644 --- a/src/Test/Perf/runner.csx +++ b/src/Test/Perf/runner.csx @@ -41,13 +41,22 @@ foreach (dynamic test in testInstances) for (int i = 0; i < iterations; i++) { - traceManager.StartScenarios(); traceManager.Start(); - traceManager.StartScenario(test.Name + i, test.MeasuredProc); - traceManager.StartEvent(); - test.Test(); - traceManager.EndEvent(); - traceManager.EndScenario(); + traceManager.StartScenarios(); + + if (test.ProvidesScenarios) + { + traceManager.WriteScenarios(test.GetScenarios()); + test.Test(); + } + else + { + traceManager.StartScenario(test.Name + i, test.MeasuredProc); + traceManager.StartEvent(); + test.Test(); + traceManager.EndEvent(); + traceManager.EndScenario(); + } traceManager.EndScenarios(); traceManager.WriteScenariosFileToDisk(); diff --git a/src/Test/Perf/tests/csharp/csharp_compiler.csx b/src/Test/Perf/tests/csharp/csharp_compiler.csx index cd03bed1a4945..0b98e8c862a1a 100644 --- a/src/Test/Perf/tests/csharp/csharp_compiler.csx +++ b/src/Test/Perf/tests/csharp/csharp_compiler.csx @@ -30,6 +30,11 @@ class CSharpCompilerTest: PerfTest public override int Iterations => 2; public override string Name => "csharp " + _rspFile; public override string MeasuredProc => "csc"; + public override bool ProvidesScenarios => false; + public override string[] GetScenarios() + { + throw new System.NotImplementedException(); + } } TestThisPlease( diff --git a/src/Test/Perf/tests/helloworld/hello_world.csx b/src/Test/Perf/tests/helloworld/hello_world.csx index be1a29a405a58..89353eed5b61c 100644 --- a/src/Test/Perf/tests/helloworld/hello_world.csx +++ b/src/Test/Perf/tests/helloworld/hello_world.csx @@ -24,6 +24,11 @@ class HelloWorldTest: PerfTest public override int Iterations => 2; public override string Name => "hello world"; public override string MeasuredProc => "csc"; + public override bool ProvidesScenarios => false; + public override string[] GetScenarios() + { + throw new System.NotImplementedException(); + } } TestThisPlease(new HelloWorldTest()); diff --git a/src/Test/Perf/util/scenario_generator_util.csx b/src/Test/Perf/util/scenario_generator_util.csx index 08b5739a140b3..c1497ec40e800 100644 --- a/src/Test/Perf/util/scenario_generator_util.csx +++ b/src/Test/Perf/util/scenario_generator_util.csx @@ -51,7 +51,7 @@ public class ScenarioGenerator public void AddStartEvent(int absoluteInstance) { - WriteToBuffer($@""); + WriteToBuffer($@""); } public void AddEndEvent() @@ -63,6 +63,11 @@ public class ScenarioGenerator { WriteToBuffer($@""); } + + public void AddLine(string line) + { + WriteToBuffer(line); + } public void WriteToDisk() { diff --git a/src/Test/Perf/util/test_util.csx b/src/Test/Perf/util/test_util.csx index aaa54b1267125..5d7da4df71c5a 100644 --- a/src/Test/Perf/util/test_util.csx +++ b/src/Test/Perf/util/test_util.csx @@ -138,6 +138,8 @@ abstract class PerfTest: RelativeDirectory { Log(description + ": " + value.ToString()); } + public abstract bool ProvidesScenarios { get; } + public abstract string[] GetScenarios(); public abstract void Setup(); public abstract void Test(); public abstract int Iterations { get; } diff --git a/src/Test/Perf/util/trace_manager_util.csx b/src/Test/Perf/util/trace_manager_util.csx index 987c0bb4ca026..38d6693b60813 100644 --- a/src/Test/Perf/util/trace_manager_util.csx +++ b/src/Test/Perf/util/trace_manager_util.csx @@ -21,6 +21,7 @@ interface ITraceManager void StartScenario(string scenarioName, string processName); void StartScenarios(); void Stop(); + void WriteScenarios(string[] scenarios); void WriteScenariosFileToDisk(); } @@ -106,6 +107,10 @@ class NoOpTraceManager : ITraceManager { } + public void WriteScenarios(string[] scenarios) + { + } + public void WriteScenariosFileToDisk() { } @@ -209,6 +214,14 @@ class TraceManager: ITraceManager { _scenarioGenerator.AddScenariosFileEnd(); } + + public void WriteScenarios(string[] scenarios) + { + foreach (var line in scenarios) + { + _scenarioGenerator.AddLine(line); + } + } public void WriteScenariosFileToDisk() {