comparison upreckon-vcs @ 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 179bad0d29f4
comparison
equal deleted inserted replaced
84:953a5baa406d 85:741ae3391b61
61 61
62 import config, itertools, os, subprocess, sys, time 62 import config, itertools, os, subprocess, sys, time
63 63
64 if options.legacy: 64 if options.legacy:
65 compat.pseudobuiltins += 'xrange', 65 compat.pseudobuiltins += 'xrange',
66
67 if options.autotime:
68 # This is really a dirty hack that assumes that sleep() does not spend
69 # the CPU time of the current process and that if clock() measures
70 # wall-clock time, then it is more precise than time() is. Both these
71 # assumptions are true on all platforms I have tested this on so far,
72 # but I am not aware of any guarantee that they will both be true
73 # on every other platform.
74 c = time.clock()
75 time.sleep(1)
76 c = time.clock() - c
77 if int(c + .5) == 1:
78 clock = time.clock
79 else:
80 clock = time.time
81 elif sys.platform == 'win32':
82 clock = time.clock
83 else:
84 clock = time.time
85 66
86 try: 67 try:
87 import testcases 68 import testcases
88 except ImportError: 69 except ImportError:
89 import_error(sys.exc_info()[1]) 70 import_error(sys.exc_info()[1])