Skip to content

Commit

Permalink
Merge pull request #172 from VJalili/val_scripts
Browse files Browse the repository at this point in the history
Improvements to the benchmarking script
  • Loading branch information
VJalili committed Oct 5, 2022
2 parents 21d321b + d384b7a commit 8471735
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
27 changes: 22 additions & 5 deletions Benchmark/CLI/CommandLineInterface.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;

namespace Genometric.MSPC.Benchmark.CLI
{
internal class CommandLineInterface
{
private readonly RootCommand _rootCmd;
private readonly Parser _parser;

public CommandLineInterface(Func<string[], DirectoryInfo, int, Task> handler)
{
Expand Down Expand Up @@ -40,7 +42,7 @@ public CommandLineInterface(Func<string[], DirectoryInfo, int, Task> handler)
};
maxRepCount.AddAlias("-c");

_rootCmd = new RootCommand(
var rootCmd = new RootCommand(
"Benchmarks given versions of MSPC using the given data cohort. " +
"It records the runtime and peak memory usage.")
{
Expand All @@ -49,16 +51,31 @@ public CommandLineInterface(Func<string[], DirectoryInfo, int, Task> handler)
maxRepCount
};

_rootCmd.SetHandler(async (releases, dir, repCount) =>
rootCmd.SetHandler(async (releases, dir, repCount) =>
{
await handler(releases, dir, repCount);
},
},
releaseOption, dataDirOption, maxRepCount);

_parser = new CommandLineBuilder(rootCmd)
.UseExceptionHandler((e, context) =>
{
Console.Error.WriteLine(e.Message);
}, 1)
.UseHelp()
.UseEnvironmentVariableDirective()
.UseParseDirective()
.UseSuggestDirective()
.RegisterWithDotnetSuggest()
.UseTypoCorrections()
.UseParseErrorReporting()
.CancelOnProcessTermination()
.Build();
}

public async Task<int> InvokeAsync(string[] args)
{
return await _rootCmd.InvokeAsync(args);
return await _parser.InvokeAsync(args);
}
}
}
3 changes: 3 additions & 0 deletions Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public static async Task<int> Main(string[] args)

public static async Task Handler(string[] releases, DirectoryInfo dataDir, int maxRepCount)
{
if (!dataDir.Exists)
throw new DirectoryNotFoundException($"{dataDir.FullName} does not exist.");

var resultsFilename = Path.Join(
dataDir.FullName,
$"mspc_versions_benchmarking_results_" +
Expand Down
2 changes: 1 addition & 1 deletion Benchmark/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private bool TryRunVerSpecificConfig(string version)

private async Task<(bool, string)> TryLocalize()
{
var dir = Path.Join(Path.GetTempPath(), "mspc", Version.ToLower().Replace(".", "_"));
var dir = Path.Combine(Environment.CurrentDirectory, "mspc", Version.ToLower().Replace(".", "_"));
if (Directory.Exists(dir))
return (true, dir);

Expand Down

0 comments on commit 8471735

Please sign in to comment.