16
16
from benchmarks .pyvsc .in_keyword import vsc_in , cr_in , cr_in_order
17
17
from benchmarks .pyvsc .ldinstr import vsc_ldinstr
18
18
from benchmarks .pyvsc .randlist import vscRandListSumZero , \
19
- crRandListSumZero , vscRandListUnique , crRandListUnique
19
+ crRandListSumZero , vscRandListUnique , crRandListUnique , \
20
+ crRandListSumZeroFaster , crRandListUniqueFaster
20
21
from examples .ldinstr import ldInstr
21
22
22
23
@@ -122,13 +123,17 @@ def test_randlist_sumzero(self):
122
123
randobjs = {
123
124
'vsc' : vscRandListSumZero (),
124
125
'cr' : crRandListSumZero (Random (0 )),
126
+ 'cr_faster' : crRandListSumZeroFaster (Random (0 )),
125
127
}
126
128
def check (results ):
127
129
self .assertGreater (results ['cr' ][1 ], results ['vsc' ][1 ])
130
+ self .assertGreater (results ['cr_faster' ][1 ], results ['vsc' ][1 ])
128
131
# This testcase is typically 20x faster, which may vary depending
129
132
# on machine. Ensure it doesn't fall below 15x.
130
133
speedup = results ['cr' ][1 ] / results ['vsc' ][1 ]
131
134
self .assertGreater (speedup , 15 , "Performance has degraded!" )
135
+ speedup = results ['cr_faster' ][1 ] / results ['vsc' ][1 ]
136
+ self .assertGreater (speedup , 15 , "Performance has degraded!" )
132
137
self .run_benchmark (randobjs , 100 , check )
133
138
134
139
def test_randlist_unique (self ):
@@ -138,12 +143,19 @@ def test_randlist_unique(self):
138
143
randobjs = {
139
144
'vsc' : vscRandListUnique (),
140
145
'cr' : crRandListUnique (Random (0 )),
146
+ 'cr_faster' : crRandListUniqueFaster (Random (0 )),
141
147
}
142
148
def check (results ):
149
+ self .assertGreater (results ['cr_faster' ][1 ], results ['vsc' ][1 ])
143
150
self .assertGreater (results ['cr' ][1 ], results ['vsc' ][1 ])
151
+ # With the naive solver, this testcase is typically 3-4x faster,
152
+ # which may vary depending on machine. Ensure it doesn't fall
153
+ # below 2x.
154
+ speedup = results ['cr' ][1 ] / results ['vsc' ][1 ]
155
+ self .assertGreater (speedup , 2 , "Performance has degraded!" )
144
156
# This testcase is typically 10-13x faster, which may vary depending
145
157
# on machine. Ensure it doesn't fall below 10x.
146
- speedup = results ['cr ' ][1 ] / results ['vsc' ][1 ]
158
+ speedup = results ['cr_faster ' ][1 ] / results ['vsc' ][1 ]
147
159
self .assertGreater (speedup , 10 , "Performance has degraded!" )
148
160
self .run_benchmark (randobjs , 100 , check )
149
161
0 commit comments