125 runbench(path); |
125 runbench(path); |
126 if (typeof tests[n].actual !== 'undefined') { |
126 if (typeof tests[n].actual !== 'undefined') { |
127 assertEq(tests[n].actual(), tests[n].expected()); |
127 assertEq(tests[n].actual(), tests[n].expected()); |
128 } |
128 } |
129 |
129 |
|
130 var times = 0; |
130 if (typeof tests[n].rerun !== 'undefined' && tests[n].times > 0) { |
131 if (typeof tests[n].rerun !== 'undefined' && tests[n].times > 0) { |
131 pprint("rerunning " + tests[n].name + " " + tests[n].times + " times..."); |
132 pprint("rerunning " + tests[n].name + " " + tests[n].times + " times..."); |
132 var times = 0; |
|
133 var to = tests[n].times; |
133 var to = tests[n].times; |
134 |
134 |
135 var elemsPerPercent = to / 100; |
135 var elemsPerPercent = to / 100; |
136 var po = 0|(to / 10); |
136 var po = 0|(to / 10); |
137 |
137 |
138 times = 0; |
138 pprint("Doing warmup."); |
139 for (; times < to; times++) { |
139 for (times = 0; times < to; times++) { |
|
140 initrandom(); |
|
141 tests[n].rerun(); |
|
142 } |
|
143 |
|
144 pprint("Doing hot runs."); |
|
145 for (times = 0; times < to; times++) { |
140 initrandom(); |
146 initrandom(); |
141 tests[n].rerun(); |
147 tests[n].rerun(); |
142 if ((times % (po|0)) == 0) { |
148 if ((times % (po|0)) == 0) { |
143 pprint(times/to * 100 + "%"); |
149 pprint("\t" + times/to * 100 + "%"); |
144 } |
150 } |
145 } |
151 } |
146 } |
152 } |
147 |
153 |
148 var t = new Date - dd; |
154 var t = Math.round(((new Date - dd) / (times == 0 ? 1 : times)) * 100 / 100); |
149 pprint("time: " + t + " ms"); |
155 pprint("time per iteration: " + t + " ms"); |
150 if (typeof tests[n].actual !== 'undefined') { |
156 if (typeof tests[n].actual !== 'undefined') { |
151 assertEq(tests[n].actual(), tests[n].expected()); |
157 assertEq(tests[n].actual(), tests[n].expected()); |
152 } |
158 } |
153 res.push(t); |
159 res.push(t); |
154 |
160 |
155 pprint(""); |
161 pprint(""); |
156 |
162 |
157 changed = true; |
163 changed = true; |
158 } catch(e) { |
164 } catch(e) { |
159 if(runall) { |
165 if (runall) { |
160 print("FAIL!"); |
166 print("FAIL!"); |
161 } else { |
167 } else { |
162 throw e; |
168 throw e; |
163 } |
169 } |
164 } |
170 } |