Issue #5788: `datetime.timedelta` objects get a new `total_seconds()` method returning
[python.git] / Tools / pybench / Exceptions.py
blobeff69c717b234012a6a0fb1ef6c1012fb4ee43a2
1 from pybench import Test
3 class TryRaiseExcept(Test):
5 version = 2.0
6 operations = 2 + 3 + 3
7 rounds = 80000
9 def test(self):
11 error = ValueError
13 for i in xrange(self.rounds):
14 try:
15 raise error
16 except:
17 pass
18 try:
19 raise error
20 except:
21 pass
22 try:
23 raise error,"something"
24 except:
25 pass
26 try:
27 raise error,"something"
28 except:
29 pass
30 try:
31 raise error,"something"
32 except:
33 pass
34 try:
35 raise error("something")
36 except:
37 pass
38 try:
39 raise error("something")
40 except:
41 pass
42 try:
43 raise error("something")
44 except:
45 pass
47 def calibrate(self):
49 error = ValueError
51 for i in xrange(self.rounds):
52 pass
55 class TryExcept(Test):
57 version = 2.0
58 operations = 15 * 10
59 rounds = 150000
61 def test(self):
63 for i in xrange(self.rounds):
64 try:
65 pass
66 except:
67 pass
68 try:
69 pass
70 except:
71 pass
72 try:
73 pass
74 except:
75 pass
76 try:
77 pass
78 except:
79 pass
80 try:
81 pass
82 except:
83 pass
84 try:
85 pass
86 except:
87 pass
88 try:
89 pass
90 except:
91 pass
92 try:
93 pass
94 except:
95 pass
96 try:
97 pass
98 except:
99 pass
100 try:
101 pass
102 except:
103 pass
105 try:
106 pass
107 except:
108 pass
109 try:
110 pass
111 except:
112 pass
113 try:
114 pass
115 except:
116 pass
117 try:
118 pass
119 except:
120 pass
121 try:
122 pass
123 except:
124 pass
125 try:
126 pass
127 except:
128 pass
129 try:
130 pass
131 except:
132 pass
133 try:
134 pass
135 except:
136 pass
137 try:
138 pass
139 except:
140 pass
141 try:
142 pass
143 except:
144 pass
147 try:
148 pass
149 except:
150 pass
151 try:
152 pass
153 except:
154 pass
155 try:
156 pass
157 except:
158 pass
159 try:
160 pass
161 except:
162 pass
163 try:
164 pass
165 except:
166 pass
167 try:
168 pass
169 except:
170 pass
171 try:
172 pass
173 except:
174 pass
175 try:
176 pass
177 except:
178 pass
179 try:
180 pass
181 except:
182 pass
183 try:
184 pass
185 except:
186 pass
189 try:
190 pass
191 except:
192 pass
193 try:
194 pass
195 except:
196 pass
197 try:
198 pass
199 except:
200 pass
201 try:
202 pass
203 except:
204 pass
205 try:
206 pass
207 except:
208 pass
209 try:
210 pass
211 except:
212 pass
213 try:
214 pass
215 except:
216 pass
217 try:
218 pass
219 except:
220 pass
221 try:
222 pass
223 except:
224 pass
225 try:
226 pass
227 except:
228 pass
231 try:
232 pass
233 except:
234 pass
235 try:
236 pass
237 except:
238 pass
239 try:
240 pass
241 except:
242 pass
243 try:
244 pass
245 except:
246 pass
247 try:
248 pass
249 except:
250 pass
251 try:
252 pass
253 except:
254 pass
255 try:
256 pass
257 except:
258 pass
259 try:
260 pass
261 except:
262 pass
263 try:
264 pass
265 except:
266 pass
267 try:
268 pass
269 except:
270 pass
272 try:
273 pass
274 except:
275 pass
276 try:
277 pass
278 except:
279 pass
280 try:
281 pass
282 except:
283 pass
284 try:
285 pass
286 except:
287 pass
288 try:
289 pass
290 except:
291 pass
292 try:
293 pass
294 except:
295 pass
296 try:
297 pass
298 except:
299 pass
300 try:
301 pass
302 except:
303 pass
304 try:
305 pass
306 except:
307 pass
308 try:
309 pass
310 except:
311 pass
313 try:
314 pass
315 except:
316 pass
317 try:
318 pass
319 except:
320 pass
321 try:
322 pass
323 except:
324 pass
325 try:
326 pass
327 except:
328 pass
329 try:
330 pass
331 except:
332 pass
333 try:
334 pass
335 except:
336 pass
337 try:
338 pass
339 except:
340 pass
341 try:
342 pass
343 except:
344 pass
345 try:
346 pass
347 except:
348 pass
349 try:
350 pass
351 except:
352 pass
355 try:
356 pass
357 except:
358 pass
359 try:
360 pass
361 except:
362 pass
363 try:
364 pass
365 except:
366 pass
367 try:
368 pass
369 except:
370 pass
371 try:
372 pass
373 except:
374 pass
375 try:
376 pass
377 except:
378 pass
379 try:
380 pass
381 except:
382 pass
383 try:
384 pass
385 except:
386 pass
387 try:
388 pass
389 except:
390 pass
391 try:
392 pass
393 except:
394 pass
397 try:
398 pass
399 except:
400 pass
401 try:
402 pass
403 except:
404 pass
405 try:
406 pass
407 except:
408 pass
409 try:
410 pass
411 except:
412 pass
413 try:
414 pass
415 except:
416 pass
417 try:
418 pass
419 except:
420 pass
421 try:
422 pass
423 except:
424 pass
425 try:
426 pass
427 except:
428 pass
429 try:
430 pass
431 except:
432 pass
433 try:
434 pass
435 except:
436 pass
439 try:
440 pass
441 except:
442 pass
443 try:
444 pass
445 except:
446 pass
447 try:
448 pass
449 except:
450 pass
451 try:
452 pass
453 except:
454 pass
455 try:
456 pass
457 except:
458 pass
459 try:
460 pass
461 except:
462 pass
463 try:
464 pass
465 except:
466 pass
467 try:
468 pass
469 except:
470 pass
471 try:
472 pass
473 except:
474 pass
475 try:
476 pass
477 except:
478 pass
480 try:
481 pass
482 except:
483 pass
484 try:
485 pass
486 except:
487 pass
488 try:
489 pass
490 except:
491 pass
492 try:
493 pass
494 except:
495 pass
496 try:
497 pass
498 except:
499 pass
500 try:
501 pass
502 except:
503 pass
504 try:
505 pass
506 except:
507 pass
508 try:
509 pass
510 except:
511 pass
512 try:
513 pass
514 except:
515 pass
516 try:
517 pass
518 except:
519 pass
521 try:
522 pass
523 except:
524 pass
525 try:
526 pass
527 except:
528 pass
529 try:
530 pass
531 except:
532 pass
533 try:
534 pass
535 except:
536 pass
537 try:
538 pass
539 except:
540 pass
541 try:
542 pass
543 except:
544 pass
545 try:
546 pass
547 except:
548 pass
549 try:
550 pass
551 except:
552 pass
553 try:
554 pass
555 except:
556 pass
557 try:
558 pass
559 except:
560 pass
563 try:
564 pass
565 except:
566 pass
567 try:
568 pass
569 except:
570 pass
571 try:
572 pass
573 except:
574 pass
575 try:
576 pass
577 except:
578 pass
579 try:
580 pass
581 except:
582 pass
583 try:
584 pass
585 except:
586 pass
587 try:
588 pass
589 except:
590 pass
591 try:
592 pass
593 except:
594 pass
595 try:
596 pass
597 except:
598 pass
599 try:
600 pass
601 except:
602 pass
605 try:
606 pass
607 except:
608 pass
609 try:
610 pass
611 except:
612 pass
613 try:
614 pass
615 except:
616 pass
617 try:
618 pass
619 except:
620 pass
621 try:
622 pass
623 except:
624 pass
625 try:
626 pass
627 except:
628 pass
629 try:
630 pass
631 except:
632 pass
633 try:
634 pass
635 except:
636 pass
637 try:
638 pass
639 except:
640 pass
641 try:
642 pass
643 except:
644 pass
647 try:
648 pass
649 except:
650 pass
651 try:
652 pass
653 except:
654 pass
655 try:
656 pass
657 except:
658 pass
659 try:
660 pass
661 except:
662 pass
663 try:
664 pass
665 except:
666 pass
667 try:
668 pass
669 except:
670 pass
671 try:
672 pass
673 except:
674 pass
675 try:
676 pass
677 except:
678 pass
679 try:
680 pass
681 except:
682 pass
683 try:
684 pass
685 except:
686 pass
688 def calibrate(self):
690 for i in xrange(self.rounds):
691 pass
693 ### Test to make Fredrik happy...
695 if __name__ == '__main__':
696 import timeit
697 timeit.TestClass = TryRaiseExcept
698 timeit.main(['-s', 'test = TestClass(); test.rounds = 1000',
699 'test.test()'])