Last active
October 7, 2019 09:30
-
-
Save fladd/e29e65b9e34dd72121630a0981b02975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
titles = ("Clock", "Implementation", "Monotonic", "Adjustable", "Resolution") | |
print("".join(str(x).ljust(30) for x in titles)) | |
print("".join(("-" * len(x)).ljust(30) for x in titles)) | |
for clock in ("time", | |
"clock", | |
"monotonic", | |
"perf_counter", | |
"process_time"): | |
info = time.get_clock_info(clock) | |
infos = [clock, info.implementation, info.monotonic, info.adjustable, info.resolution] | |
print("".join(str(x).ljust(30) for x in infos)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import time | |
import expyriment as xpy | |
LOOPS = 10 ** 6 | |
clocks = {"clock": time.clock, | |
"time": time.time, | |
"time_ns": time.time_ns, | |
"monotonic": time.monotonic, | |
"monotonic_ns": time.monotonic_ns, | |
"perf_counter": time.perf_counter, | |
"perf_counter_ns": time.perf_counter_ns, | |
"process_time": time.process_time, | |
"process_time_ns": time.process_time_ns, | |
"expyriment": xpy.misc.Clock().monotonic_time} | |
for clock in clocks: | |
min_dt = [abs(clocks[clock]() - clocks[clock]()) | |
for _ in range(LOOPS)] | |
min_dt = min(filter(bool, min_dt)) | |
if clock.endswith("ns"): | |
print("min " + clock + " delta: %s ns" % min_dt) | |
else: | |
print("min " + clock + " delta: %s ns" % math.ceil(min_dt * 1e9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is expyriment so slow (at least under Linux)?