File: test__benchmarks.py

package info (click to toggle)
python-gevent 0.13.6-1%2Bnmu3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,324 kB
  • sloc: python: 13,296; makefile: 95; ansic: 37
file content (43 lines) | stat: -rw-r--r-- 821 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys
import glob
import mysubprocess as subprocess
import time


def system(command):
    p = subprocess.Popen(command, shell=True)
    try:
        start = time.time()
        while time.time() < start + 10 and p.poll() is None:
            time.sleep(0.1)
        if p.poll() is None:
            p.kill()
            return 'KILLED'
        return p.poll()
    finally:
        if p.poll() is None:
            p.kill()


modules = set()

for path in glob.glob('bench_*.py'):
    modules.add(path)

assert modules

error = 0

if __name__ == '__main__':

    for path in modules:
        print path
        sys.stdout.flush()
        res = system('%s %s all' % (sys.executable, path))
        if res:
            error = 1
            print path, 'failed'
        print '-----'

    if error:
        sys.exit(1)