|
@@ -136,7 +136,6 @@ public class UICatalogApp
|
|
.Select (d => d!.Name)
|
|
.Select (d => d!.Name)
|
|
.ToArray ()
|
|
.ToArray ()
|
|
);
|
|
);
|
|
-
|
|
|
|
driverOption.AddAlias ("-d");
|
|
driverOption.AddAlias ("-d");
|
|
driverOption.AddAlias ("--d");
|
|
driverOption.AddAlias ("--d");
|
|
|
|
|
|
@@ -144,6 +143,10 @@ public class UICatalogApp
|
|
benchmarkFlag.AddAlias ("-b");
|
|
benchmarkFlag.AddAlias ("-b");
|
|
benchmarkFlag.AddAlias ("--b");
|
|
benchmarkFlag.AddAlias ("--b");
|
|
|
|
|
|
|
|
+ Option<string> resultsFile = new Option<string> ("--file", "The file to save benchmark results to. If not specified with --benchmark, the results will be displayed in a TableView.");
|
|
|
|
+ resultsFile.AddAlias ("-f");
|
|
|
|
+ resultsFile.AddAlias ("--f");
|
|
|
|
+
|
|
Argument<string> scenarioArgument = new Argument<string> (
|
|
Argument<string> scenarioArgument = new Argument<string> (
|
|
"scenario",
|
|
"scenario",
|
|
description: "The name of the scenario to run.",
|
|
description: "The name of the scenario to run.",
|
|
@@ -155,17 +158,20 @@ public class UICatalogApp
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
- var rootCommand =
|
|
|
|
- new RootCommand ("A comprehensive sample library for Terminal.Gui") { scenarioArgument, benchmarkFlag, driverOption };
|
|
|
|
|
|
+ var rootCommand = new RootCommand ("A comprehensive sample library for Terminal.Gui")
|
|
|
|
+ {
|
|
|
|
+ scenarioArgument, benchmarkFlag, resultsFile, driverOption,
|
|
|
|
+ };
|
|
|
|
|
|
rootCommand.SetHandler (
|
|
rootCommand.SetHandler (
|
|
context =>
|
|
context =>
|
|
{
|
|
{
|
|
var options = new Options
|
|
var options = new Options
|
|
{
|
|
{
|
|
|
|
+ Scenario = context.ParseResult.GetValueForArgument (scenarioArgument),
|
|
Driver = context.ParseResult.GetValueForOption (driverOption) ?? string.Empty,
|
|
Driver = context.ParseResult.GetValueForOption (driverOption) ?? string.Empty,
|
|
Benchmark = context.ParseResult.GetValueForOption (benchmarkFlag),
|
|
Benchmark = context.ParseResult.GetValueForOption (benchmarkFlag),
|
|
- Scenario = context.ParseResult.GetValueForArgument (scenarioArgument),
|
|
|
|
|
|
+ ResultsFile = context.ParseResult.GetValueForOption (resultsFile) ?? string.Empty,
|
|
/* etc. */
|
|
/* etc. */
|
|
};
|
|
};
|
|
|
|
|
|
@@ -176,6 +182,7 @@ public class UICatalogApp
|
|
|
|
|
|
rootCommand.Invoke (args);
|
|
rootCommand.Invoke (args);
|
|
|
|
|
|
|
|
+
|
|
UICatalogMain (_options);
|
|
UICatalogMain (_options);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -404,7 +411,7 @@ public class UICatalogApp
|
|
Application.Init (driverName: _forceDriver);
|
|
Application.Init (driverName: _forceDriver);
|
|
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
|
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
|
|
|
|
|
- Application.Screen = new (0, 0,120, 50);
|
|
|
|
|
|
+ Application.Screen = new (0, 0, 120, 50);
|
|
scenario.Main ();
|
|
scenario.Main ();
|
|
|
|
|
|
BenchmarkResults? results = null;
|
|
BenchmarkResults? results = null;
|
|
@@ -435,19 +442,26 @@ public class UICatalogApp
|
|
|
|
|
|
if (maxScenarios == 0)
|
|
if (maxScenarios == 0)
|
|
{
|
|
{
|
|
- //break;
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (resultsList.Count > 0)
|
|
if (resultsList.Count > 0)
|
|
{
|
|
{
|
|
- var output = JsonSerializer.Serialize (
|
|
|
|
- resultsList,
|
|
|
|
- new JsonSerializerOptions ()
|
|
|
|
- {
|
|
|
|
- WriteIndented = true
|
|
|
|
- });
|
|
|
|
- Console.WriteLine (output);
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty (_options.ResultsFile))
|
|
|
|
+ {
|
|
|
|
+ var output = JsonSerializer.Serialize (
|
|
|
|
+ resultsList,
|
|
|
|
+ new JsonSerializerOptions ()
|
|
|
|
+ {
|
|
|
|
+ WriteIndented = true
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ using var file = File.CreateText (_options.ResultsFile);
|
|
|
|
+ file.Write (output);
|
|
|
|
+ file.Close ();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
Application.Init ();
|
|
Application.Init ();
|
|
|
|
|
|
@@ -542,7 +556,7 @@ public class UICatalogApp
|
|
UpdatedCount = resultsList.Sum (r => r.UpdatedCount),
|
|
UpdatedCount = resultsList.Sum (r => r.UpdatedCount),
|
|
IterationCount = resultsList.Sum (r => r.IterationCount),
|
|
IterationCount = resultsList.Sum (r => r.IterationCount),
|
|
};
|
|
};
|
|
- dt.Rows.Add(
|
|
|
|
|
|
+ dt.Rows.Add (
|
|
totalRow.Scenario,
|
|
totalRow.Scenario,
|
|
totalRow.Duration,
|
|
totalRow.Duration,
|
|
totalRow.RefreshedCount,
|
|
totalRow.RefreshedCount,
|
|
@@ -1316,11 +1330,15 @@ public class UICatalogApp
|
|
|
|
|
|
private struct Options
|
|
private struct Options
|
|
{
|
|
{
|
|
|
|
+ public bool Version;
|
|
|
|
+
|
|
public string Driver;
|
|
public string Driver;
|
|
|
|
|
|
public string Scenario;
|
|
public string Scenario;
|
|
|
|
|
|
public bool Benchmark;
|
|
public bool Benchmark;
|
|
|
|
+
|
|
|
|
+ public string ResultsFile;
|
|
/* etc. */
|
|
/* etc. */
|
|
}
|
|
}
|
|
}
|
|
}
|