1616from benchmarks .pyvsc .in_keyword import vsc_in , cr_in , cr_in_order
1717from benchmarks .pyvsc .ldinstr import vsc_ldinstr
1818from benchmarks .pyvsc .randlist import vscRandListSumZero , \
19- crRandListSumZero , vscRandListUnique , crRandListUnique
19+ crRandListSumZero , vscRandListUnique , crRandListUnique , \
20+ crRandListSumZeroFaster , crRandListUniqueFaster
2021from examples .ldinstr import ldInstr
2122
2223
@@ -122,13 +123,17 @@ def test_randlist_sumzero(self):
122123 randobjs = {
123124 'vsc' : vscRandListSumZero (),
124125 'cr' : crRandListSumZero (Random (0 )),
126+ 'cr_faster' : crRandListSumZeroFaster (Random (0 )),
125127 }
126128 def check (results ):
127129 self .assertGreater (results ['cr' ][1 ], results ['vsc' ][1 ])
130+ self .assertGreater (results ['cr_faster' ][1 ], results ['vsc' ][1 ])
128131 # This testcase is typically 20x faster, which may vary depending
129132 # on machine. Ensure it doesn't fall below 15x.
130133 speedup = results ['cr' ][1 ] / results ['vsc' ][1 ]
131134 self .assertGreater (speedup , 15 , "Performance has degraded!" )
135+ speedup = results ['cr_faster' ][1 ] / results ['vsc' ][1 ]
136+ self .assertGreater (speedup , 15 , "Performance has degraded!" )
132137 self .run_benchmark (randobjs , 100 , check )
133138
134139 def test_randlist_unique (self ):
@@ -138,12 +143,19 @@ def test_randlist_unique(self):
138143 randobjs = {
139144 'vsc' : vscRandListUnique (),
140145 'cr' : crRandListUnique (Random (0 )),
146+ 'cr_faster' : crRandListUniqueFaster (Random (0 )),
141147 }
142148 def check (results ):
149+ self .assertGreater (results ['cr_faster' ][1 ], results ['vsc' ][1 ])
143150 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!" )
144156 # This testcase is typically 10-13x faster, which may vary depending
145157 # 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 ]
147159 self .assertGreater (speedup , 10 , "Performance has degraded!" )
148160 self .run_benchmark (randobjs , 100 , check )
149161
0 commit comments