Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (39 sloc) 1.124 kB
2290ac7 @mitsuhiko Added benchmark tests
authored
1 #!/usr/bin/env python
2 """
3 Runs the benchmarks
4 """
5 import sys
6 import os
7 import re
8 from subprocess import Popen
9
10 try:
11 from pkg_resources import get_distribution
12 version = get_distribution('Logbook').version
13 except Exception:
14 version = 'unknown version'
15
16
17 _filename_re = re.compile(r'^bench_(.*?)\.py$')
18 bench_directory = os.path.abspath(os.path.dirname(__file__))
19
20
21 def list_benchmarks():
22 result = []
23 for name in os.listdir(bench_directory):
24 match = _filename_re.match(name)
25 if match is not None:
26 result.append(match.group(1))
ba8171a @mitsuhiko Added some logging benchmarks too
authored
27 result.sort(key=lambda x: (x.startswith('logging_'), x.lower()))
2290ac7 @mitsuhiko Added benchmark tests
authored
28 return result
29
30
31 def run_bench(name):
32 sys.stdout.write('%-32s' % name)
33 sys.stdout.flush()
34 Popen([sys.executable, '-mtimeit', '-s',
35 'from bench_%s import run' % name,
36 'run()']).wait()
37
38
39 def main():
40 print '=' * 80
41 print 'Running benchmark with Logbook %s' % version
42 print '-' * 80
43 os.chdir(bench_directory)
44 for bench in list_benchmarks():
45 run_bench(bench)
46 print '-' * 80
47
48
49 if __name__ == '__main__':
50 main()
Something went wrong with that request. Please try again.