/// <summary>Runs the benchmark.</summary> public void Run() { if (_benchmark == null) { throw new InvalidOperationException("Call Init() first."); } using (BenchmarkHelpers.CaptureConsoleOutput(_output)) { try { FillProperties(_instance, _benchmark); _output.WriteLine(); foreach (var infoLine in EnvironmentInfo.GetCurrent().ToFormattedString()) { _output.WriteLine("// {0}", infoLine); } _output.WriteLine(); new MethodInvokerLight(_job).Invoke(_job, _operationsPerInvoke, _setupAction, _runCallback, _idleCallback); } catch (Exception ex) { _output.WriteLine(ex); throw; } } }
/// <inheritdoc/> protected override async Task <Tuple <decimal, string> > InvokeTestAsync(ExceptionAggregator aggregator) { var writer = new StringWriter(); using (BenchmarkHelpers.CaptureConsoleOutput(writer)) { var result = await base.InvokeTestAsync(aggregator); writer.Flush(); var output = writer.GetStringBuilder(); if (output.Length == 0) { return(result); } return(new Tuple <decimal, string>(result.Item1, result.Item2 + output)); } }