comparison testcases.py @ 85:741ae3391b61

Moved clock/time detection into platform-specific modules and testcases
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 24 Feb 2011 23:59:48 +0000
parents 37c4ad87583c
children cd347cfca272
comparison
equal deleted inserted replaced
84:953a5baa406d 85:741ae3391b61
10 import files, problem, config 10 import files, problem, config
11 except ImportError: 11 except ImportError:
12 import __main__ 12 import __main__
13 __main__.import_error(sys.exc_info()[1]) 13 __main__.import_error(sys.exc_info()[1])
14 else: 14 else:
15 from __main__ import clock, options 15 from __main__ import options
16 16
17 import glob, re, sys, tempfile, time 17 import glob, re, sys, tempfile, time
18 from subprocess import Popen, PIPE, STDOUT 18 from subprocess import Popen, PIPE, STDOUT
19 19
20 import os 20 import os
21 devnull = open(os.path.devnull, 'w+') 21 devnull = open(os.path.devnull, 'w+')
22
23 if options.autotime:
24 # This is really a dirty hack that assumes that sleep() does not spend
25 # the CPU time of the current process and that if clock() measures
26 # wall-clock time, then it is more precise than time() is. Both these
27 # assumptions are true on all platforms I have tested this on so far,
28 # but I am not aware of any guarantee that they will both be true
29 # on every other platform.
30 c = time.clock()
31 time.sleep(1)
32 c = time.clock() - c
33 if int(c + .5) == 1:
34 clock = time.clock
35 else:
36 clock = time.time
22 37
23 try: 38 try:
24 from win32 import * 39 from win32 import *
25 except Exception: 40 except Exception:
26 from unix import * 41 from unix import *