aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-18 05:26:29 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-18 05:26:29 +0200
commit86bbaee1a545f08dc7bfb4efe5f4696d6e4dccdd (patch)
tree0b46af20d6bb4568e44148b5e89d31da298c43fc /Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI
parentd9ee0b8e11f15c2b3bae068767516bc84a5ca4ed (diff)
downloadTango-86bbaee1a545f08dc7bfb4efe5f4696d6e4dccdd.tar.gz
Tango-86bbaee1a545f08dc7bfb4efe5f4696d6e4dccdd.zip
StubUtils
Diffstat (limited to 'Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI')
-rw-r--r--Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI/Program.cs72
1 files changed, 62 insertions, 10 deletions
diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI/Program.cs b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI/Program.cs
index 3083037f8..ff172737a 100644
--- a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI/Program.cs
+++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.PerformanceTest.CLI/Program.cs
@@ -10,10 +10,63 @@ namespace Tango.StubsUtils.PerformanceTest.CLI
{
class Program
{
- private const int ROUNDS = 10000;
+ private const int ROUNDS = 100;
+ private const int DELAY = 0;
static void Main(string[] args)
{
+ PerformanceTestStandard();
+ Console.WriteLine();
+ PerformanceTestSession();
+
+ Console.WriteLine();
+ Console.WriteLine();
+ Console.WriteLine("Completed.");
+ Console.ReadLine();
+ }
+
+ private static void PerformanceTestStandard()
+ {
+ List<double> durations = new List<double>();
+
+ Stopwatch watch = new Stopwatch();
+
+ for (int i = 0; i < ROUNDS; i++)
+ {
+ watch.Restart();
+
+ Process process = new Process();
+ process.StartInfo.FileName = "tangostub.exe";
+ process.StartInfo.CreateNoWindow = true;
+ process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+ process.StartInfo.Arguments = "calculate 10 15";
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.UseShellExecute = false;
+ process.Start();
+ process.WaitForExit();
+
+ String response = process.StandardOutput.ReadToEnd();
+
+ if (!response.StartsWith("Status: OK"))
+ {
+ OnError(response);
+ return;
+ }
+
+ if (DELAY > 0)
+ {
+ Thread.Sleep(DELAY);
+ }
+
+ durations.Add(watch.ElapsedMilliseconds);
+
+ Console.SetCursorPosition(0, 0);
+ Console.Write($"Performance Test (Standard): {i + 1}/{ROUNDS}, Avg: {Math.Round(durations.Average(), 2)} ms ");
+ }
+ }
+
+ private static void PerformanceTestSession()
+ {
List<double> durations = new List<double>();
Process process = new Process();
@@ -21,7 +74,6 @@ namespace Tango.StubsUtils.PerformanceTest.CLI
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
- process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
@@ -61,22 +113,22 @@ namespace Tango.StubsUtils.PerformanceTest.CLI
String response = builder.ToString();
- if (response.StartsWith("Status: Error"))
+ if (!response.StartsWith("Status: OK"))
{
OnError(response);
return;
}
+ if (DELAY > 0)
+ {
+ Thread.Sleep(DELAY);
+ }
+
durations.Add(watch.ElapsedMilliseconds);
- Console.SetCursorPosition(0, 0);
- Console.Write($"Performance Test: {i + 1}/{ROUNDS}, Avg: {Math.Round(durations.Average(), 2)} ms ");
+ Console.SetCursorPosition(0, 1);
+ Console.Write($"Performance Test (Session) : {i + 1}/{ROUNDS}, Avg: {Math.Round(durations.Average(), 2)} ms ");
}
-
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Completed.");
- Console.ReadLine();
}
private static void OnError(String error)