Skip to content

Commit 6808e68

Browse files
close #314 - fix flaky integration test (#315)
1 parent d83b040 commit 6808e68

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/NBench.Tests.End2End/NBenchIntegrationTest.WithDependencies.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ private static TestPackage LoadPackageWithDependencies(IEnumerable<string> inclu
6565
package.AddExclude(e);
6666
}
6767

68+
// need to set this to true in order to resolve https://github.com/petabridge/NBench/issues/314
69+
package.Concurrent = true;
70+
6871
return package;
6972
}
7073
}

src/NBench/Sdk/Benchmark.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Benchmark
4343
/// <param name="invoker">The invoker used to execute benchmark and setup / cleanup methods.</param>
4444
/// <param name="writer">The output target this benchmark will write to.</param>
4545
/// <remarks>Uses the <see cref="DefaultBenchmarkAssertionRunner"/> to assert benchmark data.</remarks>
46-
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer)
46+
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer)
4747
: this(settings, invoker, writer, DefaultBenchmarkAssertionRunner.Instance) { }
4848

4949
/// <summary>
@@ -97,7 +97,7 @@ private void WarmUp()
9797
var runTime = 0L;
9898

9999
/* Pre-Warmup */
100-
100+
101101

102102
Trace.Debug("----- BEGIN PRE-WARMUP -----");
103103
/* Estimate */
@@ -128,16 +128,16 @@ private void WarmUp()
128128
{
129129
runEstimates[i - 1] = runCount;
130130
timeEstimates[i - 1] = warmupStopWatch.ElapsedTicks;
131-
131+
132132
}
133133

134134
runCount = 0;
135135
warmupStopWatch.Reset();
136136
}
137137

138138
runCount = (long)Math.Ceiling(runEstimates.Average());
139-
runTime = (long) Math.Ceiling(timeEstimates.Average());
140-
139+
runTime = (long)Math.Ceiling(timeEstimates.Average());
140+
141141
Trace.Debug(
142142
$"Throughput mode: executed {runCount} instances of {BenchmarkName} in roughly {targetTime.TotalSeconds}s. Using that figure for benchmark.");
143143
}
@@ -225,7 +225,7 @@ public void Run()
225225
{
226226
Output.Warning($"Error during previous run of {BenchmarkName}. Aborting run...");
227227
}
228-
228+
229229
}
230230

231231
public void Shutdown()
@@ -262,12 +262,12 @@ protected void PreRun()
262262
// the invoker with an inlined loop
263263
Invoker.InvokePerfSetup(WarmupData.EstimatedRunsPerSecond, _currentRun.Context);
264264
}
265-
else
265+
else
266266
{
267267
// Invoke user-defined setup method, if any
268268
Invoker.InvokePerfSetup(_currentRun.Context);
269269
}
270-
270+
271271

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

350350
// Change runs, but not on warmup

0 commit comments

Comments
 (0)