2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
4
using System . Linq ;
5
+ using System . Runtime . CompilerServices ;
5
6
using System . Reflection ;
6
7
7
8
using BenchmarkDotNet . Reports ;
@@ -12,25 +13,36 @@ namespace Python.PerformanceTests
12
13
{
13
14
public class BenchmarkTests
14
15
{
16
+ Summary summary ;
17
+
15
18
[ OneTimeSetUp ]
16
19
public void SetUp ( )
17
20
{
18
21
Environment . CurrentDirectory = Path . Combine ( DeploymentRoot , "new" ) ;
22
+ this . summary = BenchmarkRunner . Run < PythonCallingNetBenchmark > ( ) ;
23
+ Assert . IsNotEmpty ( this . summary . Reports ) ;
24
+ Assert . IsTrue ( this . summary . Reports . All ( r => r . Success ) ) ;
19
25
}
20
26
21
27
[ Test ]
22
- public void PythonCallingNet ( )
28
+ public void ReadInt64Property ( )
23
29
{
24
- var summary = BenchmarkRunner . Run < PythonCallingNetBenchmark > ( ) ;
25
-
26
- Assert . IsNotEmpty ( summary . Reports ) ;
27
- Assert . IsTrue ( summary . Reports . All ( r => r . Success ) ) ;
30
+ double optimisticPerfRatio = GetOptimisticPerfRatio ( this . summary . Reports ) ;
31
+ Assert . LessOrEqual ( optimisticPerfRatio , 0.68 ) ;
32
+ }
28
33
29
- double optimisticPerfRatio = GetOptimisticPerfRatio ( summary . Reports ) ;
30
- Assert . LessOrEqual ( optimisticPerfRatio , 1.03 ) ;
34
+ [ Test ]
35
+ public void WriteInt64Property ( )
36
+ {
37
+ double optimisticPerfRatio = GetOptimisticPerfRatio ( this . summary . Reports ) ;
38
+ Assert . LessOrEqual ( optimisticPerfRatio , 0.66 ) ;
31
39
}
32
40
33
- static double GetOptimisticPerfRatio ( IReadOnlyList < BenchmarkReport > reports ) {
41
+ static double GetOptimisticPerfRatio (
42
+ IReadOnlyList < BenchmarkReport > reports ,
43
+ [ CallerMemberName ] string methodName = null )
44
+ {
45
+ reports = reports . Where ( r => r . BenchmarkCase . Descriptor . WorkloadMethod . Name == methodName ) . ToArray ( ) ;
34
46
var baseline = reports . Single ( r => r . BenchmarkCase . Job . ResolvedId == "baseline" ) . ResultStatistics ;
35
47
var @new = reports . Single ( r => r . BenchmarkCase . Job . ResolvedId != "baseline" ) . ResultStatistics ;
36
48
double newTimeOptimistic = @new . Mean - ( @new . StandardDeviation + baseline . StandardDeviation ) * 0.5 ;
0 commit comments