summaryrefslogtreecommitdiff
path: root/testsuite/timeout/calibrate
blob: f30c628e7a90b7e175c4a69037d681b5845c76f0 (plain)
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
#!/usr/bin/env python

import math
import os
from os import *
from sys import *
try:
    from resource import *
except:
    # We don't have resource, so this is a non-UNIX machine.
    # It's probably a reasonable modern x86/x86_64 machines, so we'd
    # probably calibrate to 300 anyway; thus just print 300.
    print(300)
    exit(0)

compiler = argv[1]
compiler_name = os.path.basename(compiler)

spawnl(os.P_WAIT, compiler,
                  compiler_name, 'TimeMe.hs', '-o', 'TimeMe', '-O2')
spawnl(os.P_WAIT, './TimeMe', 'TimeMe')

xs = getrusage(RUSAGE_CHILDREN);
x = int(math.ceil(xs[0] + xs[1]))
if x < 1:
    x = 1
print (300*x)