public static GetProperty ( string key ) : string | ||
key | string | |
return | string |
/// <summary> /// NBench Runner takes the following <see cref="args"/> /// /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}] /// /// </summary> /// <param name="args">The commandline arguments</param> static int Main(string[] args) { string[] include = null; string[] exclude = null; bool concurrent = false; bool trace = false; bool teamcity = false; if (CommandLine.HasProperty("include")) { include = CommandLine.GetProperty("include").Split(','); } if (CommandLine.HasProperty("exclude")) { exclude = CommandLine.GetProperty("exclude").Split(','); } if (CommandLine.HasProperty("concurrent")) { concurrent = CommandLine.GetBool("concurrent"); } if (CommandLine.HasProperty("trace")) { trace = CommandLine.GetBool("trace"); } if (CommandLine.HasProperty("teamcity")) { teamcity = CommandLine.GetBool("teamcity"); } else { // try to auto-detect if not explicitly set teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME")); } TestPackage package = new TestPackage(CommandLine.GetFiles(args), include, exclude, concurrent) { Tracing = trace }; if (CommandLine.HasProperty("output-directory")) { package.OutputDirectory = CommandLine.GetProperty("output-directory"); } if (CommandLine.HasProperty("configuration")) { package.ConfigurationFile = CommandLine.GetProperty("configuration"); } package.TeamCity = teamcity; package.Validate(); var result = TestRunner.Run(package); return(result.AllTestsPassed ? 0 : -1); }
/// <summary> /// NBench Runner takes the following <see cref="args"/> /// /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] /// /// </summary> /// <param name="args">The commandline arguments</param> static int Main(string[] args) { string[] include = null; string[] exclude = null; bool concurrent = false; bool trace = false; if (CommandLine.HasProperty("include")) { include = CommandLine.GetProperty("include").Split(','); } if (CommandLine.HasProperty("exclude")) { exclude = CommandLine.GetProperty("exclude").Split(','); } if (CommandLine.HasProperty("concurrent")) { concurrent = CommandLine.GetBool("concurrent"); } if (CommandLine.HasProperty("trace")) { trace = CommandLine.GetBool("trace"); } TestPackage package = new TestPackage(CommandLine.GetFiles(args), include, exclude, concurrent) { Tracing = trace }; if (CommandLine.HasProperty("output-directory")) { package.OutputDirectory = CommandLine.GetProperty("output-directory"); } if (CommandLine.HasProperty("configuration")) { package.ConfigurationFile = CommandLine.GetProperty("configuration"); } package.Validate(); var result = TestRunner.Run(package); return(result.AllTestsPassed ? 0 : -1); }
/// <summary> /// NBench Runner takes the following <see cref="args"/> /// /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}] /// /// </summary> /// <param name="args">The commandline arguments</param> static int Main(string[] args) { string[] include = null; string[] exclude = null; bool concurrent = false; bool trace = false; bool teamcity = false; if (args.Length == 1 && args[0] == "--help") { CommandLine.ShowHelp(); return(0); } if (CommandLine.HasProperty(CommandLine.DiagnosticsKey)) { Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("DIAG: Executing with parameters [{0}]", CommandLine.FormatCapturedArguments()); Console.WriteLine("DIAG: Unparsed arguments [{0}]", string.Join(",", Environment.GetCommandLineArgs())); Console.WriteLine($"DIAG: Captured, but unrecognized arguments: {string.Join(",", CommandLine.Values.Value.Select(x => $"{x.Key}:[{string.Join(",", x.Value)}]"))}"); Console.ResetColor(); } if (CommandLine.HasProperty(CommandLine.IncludeKey)) { include = CommandLine.GetProperty(CommandLine.IncludeKey)?.ToArray(); } if (CommandLine.HasProperty(CommandLine.ExcludeKey)) { exclude = CommandLine.GetProperty(CommandLine.ExcludeKey)?.ToArray(); } if (CommandLine.HasProperty(CommandLine.ConcurrentKey)) { concurrent = CommandLine.GetBool(CommandLine.ConcurrentKey); } if (CommandLine.HasProperty(CommandLine.TracingKey)) { trace = CommandLine.GetBool(CommandLine.TracingKey); } if (CommandLine.HasProperty(CommandLine.TeamCityKey)) { teamcity = true; } else { // try to auto-detect if not explicitly set teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME")); } var files = CommandLine.GetFiles(args); if (files.Count == 0) { Console.WriteLine("Please provide assemblies for which to run NBench tests\n"); CommandLine.ShowHelp(); return(1); } TestPackage package = new TestPackage(files, include, exclude, concurrent) { Tracing = trace }; if (CommandLine.HasProperty(CommandLine.OutputKey)) { package.OutputDirectory = CommandLine.GetSingle(CommandLine.OutputKey); } if (CommandLine.HasProperty(CommandLine.ConfigurationKey)) { package.ConfigurationFile = CommandLine.GetSingle(CommandLine.ConfigurationKey); } package.TeamCity = teamcity; package.Validate(); var result = TestRunner.Run(package); return(result.AllTestsPassed ? 0 : -1); }
/// <summary> /// NBench Runner takes the following <see cref="args"/> /// /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] /// /// </summary> /// <param name="args">The commandline arguments</param> static int Main(string[] args) { Output = new CompositeBenchmarkOutput(new ConsoleBenchmarkOutput(), new MarkdownBenchmarkOutput(CommandLine.GetProperty("output-directory"))); Discovery = new ReflectionDiscovery(Output); string assemblyPath = Path.GetFullPath(args[0]); // TODO: See issue https://github.com/petabridge/NBench/issues/3 var assembly = AssemblyRuntimeLoader.LoadAssembly(assemblyPath); /* * Set processor affinity */ Process Proc = Process.GetCurrentProcess(); Proc.ProcessorAffinity = new IntPtr(2); // either of the first two processors /* * Set priority */ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Thread.CurrentThread.Priority = ThreadPriority.Highest; var benchmarks = Discovery.FindBenchmarks(assembly); bool anyAssertFailures = false; foreach (var benchmark in benchmarks) { Output.WriteLine($"------------ STARTING {benchmark.BenchmarkName} ---------- "); benchmark.Run(); benchmark.Finish(); // if one assert fails, all fail anyAssertFailures = anyAssertFailures || !benchmark.AllAssertsPassed; Output.WriteLine($"------------ FINISHED {benchmark.BenchmarkName} ---------- "); } return(anyAssertFailures ? -1 : 0); }
/// <summary> /// NBench Runner takes the following <see cref="args"/> /// /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}] /// /// </summary> /// <param name="args">The commandline arguments</param> static int Main(string[] args) { string[] include = null; string[] exclude = null; bool concurrent = false; bool trace = false; bool teamcity = false; if (args.Length == 1 && args[0] == "--help") { CommandLine.ShowHelp(); return(0); } if (CommandLine.HasProperty("include")) { include = CommandLine.GetProperty("include").Split(','); } if (CommandLine.HasProperty("exclude")) { exclude = CommandLine.GetProperty("exclude").Split(','); } if (CommandLine.HasProperty("concurrent")) { concurrent = CommandLine.GetBool("concurrent"); } if (CommandLine.HasProperty("trace")) { trace = CommandLine.GetBool("trace"); } if (CommandLine.HasProperty("teamcity")) { teamcity = CommandLine.GetBool("teamcity"); } else { // try to auto-detect if not explicitly set teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME")); } var files = CommandLine.GetFiles(args); if (files.Count == 0) { Console.WriteLine("Please provide assemblies for which to run NBench tests\n"); CommandLine.ShowHelp(); return(1); } TestPackage package = new TestPackage(files, include, exclude, concurrent) { Tracing = trace }; if (CommandLine.HasProperty("output-directory")) { package.OutputDirectory = CommandLine.GetProperty("output-directory"); } if (CommandLine.HasProperty("configuration")) { package.ConfigurationFile = CommandLine.GetProperty("configuration"); } package.TeamCity = teamcity; package.Validate(); var result = TestRunner.Run(package); return(result.AllTestsPassed ? 0 : -1); }