Commit 019821d4 authored by root's avatar root

Improved micro exception benchmark (hindered optimisations and allowed...

Improved micro exception benchmark (hindered optimisations and allowed comparisons with no catch block)
parent f6ddfe61
# The first custom (in this case 2000) is the recursion depth
# the second argument means:
# 0 don't throw an exception, but still have a catch block at the top
# 1 do throw an exception at the bottom of the recursion (to be caught by the top)
# 2 don't throw an exception, with no catch block
except_rpyc:
benchmark:
name: micro/except
iterations: 500
iterations: 1
source: targetexcept.py
args:
- 200
- 2000 1
language:
name: rpython
backend: c
environ:
PYPY_C_CLANG_OPT: "-O0"
PYPY_USESSION_DIR: example
PYPY_USESSION_BASENAME: except_rpyc
PYPY_C_CLANG_OPT: "-O3"
MICROBENCH_SCALE_FACTOR: "1"
callback:
name: ClockCallback
......@@ -21,10 +29,10 @@ except_rpyc:
except_rpymu_zebu:
benchmark:
name: micro/except
iterations: 500
iterations: 1
source: targetexcept.py
args:
- 200
- 2000 1
result: alloc_rpyzebu_data
language:
name: rpython
......@@ -34,6 +42,8 @@ except_rpymu_zebu:
name: ClockCallback
param: "6"
environ:
PYPY_USESSION_DIR: example
PYPY_USESSION_BASENAME: except_rpymu
MU_ZEBU: /home/isaacg/mu-impl-fast
ZEBU_BUILD: release
MICROBENCH_SCALE_FACTOR: "1"
......
DEFAULT_SCALE_FACTOR = 1000000000;
def except_raiser(n):
import os
def eprint(msg):
os.write(2, str(msg));
def except_raiser(n, c):
if n == 0:
if c != 0:
raise Exception('except');
eprint(3);
else:
eprint(4);
return 0;
else:
eprint(5);
return except_raiser(n - 1, c) + 1;
def except_catcher(n, c):
try:
return except_raiser(n, c);
except Exception:
return 0;
def fake_catcher(n):
return fake_raiser(n);
def fake_raiser(n):
if n == 0:
raise Exception('except');
eprint(4);
return 0;
else:
except_raiser(n - 1);
eprint(5);
return fake_raiser(n - 1) + 1;
def target(driver, args):
from callback import get_callback;
......@@ -17,17 +44,21 @@ def target(driver, args):
cb_param = argv[1];
n = int(argv[2]);
recursions = int(argv[3]);
c = int(argv[4]);
cb = cb_cls(cb_param);
lst = [];
for i in range(n):
cb.begin();
try:
except_raiser(recursions);
except Exception as inst:
pass; #print inst.args;
cb.end();
if c > 1:
for i in range(n):
cb.begin();
eprint(fake_catcher(recursions));
cb.end();
else:
for i in range(n):
cb.begin();
eprint(except_catcher(recursions, c));
cb.end();
cb.report();
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment