Skip to content

Commit

Permalink
close #314 - fix flaky integration test (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Feb 24, 2020
1 parent d83b040 commit 6808e68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ private static TestPackage LoadPackageWithDependencies(IEnumerable<string> inclu
package.AddExclude(e);
}

// need to set this to true in order to resolve https://github.com/petabridge/NBench/issues/314
package.Concurrent = true;

return package;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/NBench/Sdk/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Benchmark
/// <param name="invoker">The invoker used to execute benchmark and setup / cleanup methods.</param>
/// <param name="writer">The output target this benchmark will write to.</param>
/// <remarks>Uses the <see cref="DefaultBenchmarkAssertionRunner"/> to assert benchmark data.</remarks>
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer)
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer)
: this(settings, invoker, writer, DefaultBenchmarkAssertionRunner.Instance) { }

/// <summary>
Expand Down Expand Up @@ -97,7 +97,7 @@ private void WarmUp()
var runTime = 0L;

/* Pre-Warmup */


Trace.Debug("----- BEGIN PRE-WARMUP -----");
/* Estimate */
Expand Down Expand Up @@ -128,16 +128,16 @@ private void WarmUp()
{
runEstimates[i - 1] = runCount;
timeEstimates[i - 1] = warmupStopWatch.ElapsedTicks;

}

runCount = 0;
warmupStopWatch.Reset();
}

runCount = (long)Math.Ceiling(runEstimates.Average());
runTime = (long) Math.Ceiling(timeEstimates.Average());
runTime = (long)Math.Ceiling(timeEstimates.Average());

Trace.Debug(
$"Throughput mode: executed {runCount} instances of {BenchmarkName} in roughly {targetTime.TotalSeconds}s. Using that figure for benchmark.");
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public void Run()
{
Output.Warning($"Error during previous run of {BenchmarkName}. Aborting run...");
}

}

public void Shutdown()
Expand Down Expand Up @@ -262,12 +262,12 @@ protected void PreRun()
// the invoker with an inlined loop
Invoker.InvokePerfSetup(WarmupData.EstimatedRunsPerSecond, _currentRun.Context);
}
else
else
{
// Invoke user-defined setup method, if any
Invoker.InvokePerfSetup(_currentRun.Context);
}


PrepareForRun();
}
Expand Down Expand Up @@ -344,7 +344,7 @@ private void Complete(bool isEstimate = false)
_currentRun.Dispose();
Trace.Info($"Generating report for {PrintWarmupOrRun(_isWarmup)} {1 + Settings.NumberOfIterations - _pendingIterations} of {BenchmarkName}");
var report = _currentRun.ToReport(StopWatch.Elapsed);
if(!isEstimate)
if (!isEstimate)
Output.WriteRun(report, _isWarmup);

// Change runs, but not on warmup
Expand Down

0 comments on commit 6808e68

Please sign in to comment.