Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6c55d4

Browse files
committed
relax performance targets to ~10%, improve perf failure message
1 parent 340a6d1 commit a6c55d4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/perf_tests/BenchmarkTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public void SetUp()
3030
public void ReadInt64Property()
3131
{
3232
double optimisticPerfRatio = GetOptimisticPerfRatio(this.summary.Reports);
33-
Assert.LessOrEqual(optimisticPerfRatio, 0.68);
33+
AssertPerformanceIsBetterOrSame(optimisticPerfRatio, target: 0.66);
3434
}
3535

3636
[Test]
3737
public void WriteInt64Property()
3838
{
3939
double optimisticPerfRatio = GetOptimisticPerfRatio(this.summary.Reports);
40-
Assert.LessOrEqual(optimisticPerfRatio, 0.67);
40+
AssertPerformanceIsBetterOrSame(optimisticPerfRatio, target: 0.64);
4141
}
4242

4343
static double GetOptimisticPerfRatio(
@@ -61,5 +61,14 @@ static double GetOptimisticPerfRatio(
6161
}
6262

6363
public static string DeploymentRoot => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
64+
65+
public static void AssertPerformanceIsBetterOrSame(
66+
double actual, double target,
67+
double wiggleRoom = 1.1, [CallerMemberName] string testName = null) {
68+
double threshold = target * wiggleRoom;
69+
Assert.LessOrEqual(actual, threshold,
70+
$"{testName}: {actual:F3} > {threshold:F3} (target: {target:F3})"
71+
+ ": perf result is higher than the failure threshold.");
72+
}
6473
}
6574
}

0 commit comments

Comments
 (0)