Eurgh for starters using `time.time()` is a bad idea because it calls gettimeofday which is susceptible to clock changes. `time.perf_counter` is what you want to use as it can never go backwards and it will always be from the highest granularity clock.