File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,12 @@ public BaselineComparisonConfig()
20
20
21
21
var baseJob = Job . Default ;
22
22
this . Add ( baseJob
23
+ . WithId ( "baseline" )
23
24
. WithEnvironmentVariable ( EnvironmentVariableName ,
24
25
Path . Combine ( deploymentRoot , "baseline" , "Python.Runtime.dll" ) )
25
- . AsBaseline ( ) ) ;
26
+ . WithBaseline ( true ) ) ;
26
27
this . Add ( baseJob
28
+ . WithId ( "new" )
27
29
. WithEnvironmentVariable ( EnvironmentVariableName ,
28
30
Path . Combine ( deploymentRoot , "new" , "Python.Runtime.dll" ) ) ) ;
29
31
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . IO ;
4
+ using System . Linq ;
3
5
using System . Reflection ;
4
6
7
+ using BenchmarkDotNet . Reports ;
5
8
using BenchmarkDotNet . Running ;
6
9
using NUnit . Framework ;
7
10
@@ -19,8 +22,19 @@ public void SetUp()
19
22
public void PythonCallingNet ( )
20
23
{
21
24
var summary = BenchmarkRunner . Run < PythonCallingNetBenchmark > ( ) ;
22
- Console . WriteLine ( summary ) ;
23
- Assert . Inconclusive ( ) ;
25
+
26
+ Assert . IsNotEmpty ( summary . Reports ) ;
27
+ Assert . IsTrue ( summary . Reports . All ( r => r . Success ) ) ;
28
+
29
+ double optimisticPerfRatio = GetOptimisticPerfRatio ( summary . Reports ) ;
30
+ Assert . LessOrEqual ( optimisticPerfRatio , 1.03 ) ;
31
+ }
32
+
33
+ static double GetOptimisticPerfRatio ( IReadOnlyList < BenchmarkReport > reports ) {
34
+ var baseline = reports . Single ( r => r . BenchmarkCase . Job . ResolvedId == "baseline" ) . ResultStatistics ;
35
+ var @new = reports . Single ( r => r . BenchmarkCase . Job . ResolvedId != "baseline" ) . ResultStatistics ;
36
+ double newTimeOptimistic = @new . Mean - ( @new . StandardDeviation + baseline . StandardDeviation ) * 0.5 ;
37
+ return newTimeOptimistic / baseline . Mean ;
24
38
}
25
39
26
40
public static string DeploymentRoot => Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
You can’t perform that action at this time.
0 commit comments