How do I get monotonic time durations in python?
问题 I want to log how long something takes in real walltime. Currently I'm doing this: startTime = time.time() someSQLOrSomething() print "That took %.3f seconds" % (time.time() - startTime) But that will fail (produce incorrect results) if the time is adjusted while the SQL query (or whatever it is) is running. I don't want to just benchmark it. I want to log it in a live application in order to see trends on a live system. I want something like clock_gettime(CLOCK_MONOTONIC,...), but in Python.