Show More
@@ -23,6 +23,11 b' import time' | |||||
23 | # If possible (Unix), use the resource module instead of time.clock() |
|
23 | # If possible (Unix), use the resource module instead of time.clock() | |
24 | try: |
|
24 | try: | |
25 | import resource |
|
25 | import resource | |
|
26 | except ImportError: | |||
|
27 | resource = None | |||
|
28 | ||||
|
29 | # Some implementations (like jyputerlite) don't have getrusage | |||
|
30 | if resource is not None and hasattr(resource, "getrusage"): | |||
26 | def clocku(): |
|
31 | def clocku(): | |
27 | """clocku() -> floating point number |
|
32 | """clocku() -> floating point number | |
28 |
|
33 | |||
@@ -56,7 +61,9 b' try:' | |||||
56 |
|
61 | |||
57 | Similar to clock(), but return a tuple of user/system times.""" |
|
62 | Similar to clock(), but return a tuple of user/system times.""" | |
58 | return resource.getrusage(resource.RUSAGE_SELF)[:2] |
|
63 | return resource.getrusage(resource.RUSAGE_SELF)[:2] | |
59 | except ImportError: |
|
64 | ||
|
65 | ||||
|
66 | else: | |||
60 | # There is no distinction of user/system time under windows, so we just use |
|
67 | # There is no distinction of user/system time under windows, so we just use | |
61 | # time.perff_counter() for everything... |
|
68 | # time.perff_counter() for everything... | |
62 | clocku = clocks = clock = time.perf_counter |
|
69 | clocku = clocks = clock = time.perf_counter |
General Comments 0
You need to be logged in to leave comments.
Login now