calibrate 642 Bytes
Newer Older
Simon Marlow's avatar
Simon Marlow committed
1
#!/usr/bin/env python
2 3 4 5 6

import math
import os
from os import *
from sys import *
7 8 9 10 11 12
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.
13
    print(300)
14
    exit(0)
15 16 17 18 19

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

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

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