After reading this Python's time.clock() vs. time.time() accuracy? and time.process_time(), among others, I'm pretty confused.
I need CPU time spend grinding out an algorithm. I want the time right before the call and right after it returns.
start = time.time() or time.process_time()
sorted = algorithm(stuff)
end = time.time() or time.process_time()
elapsed = end - start * (1e9)
time.process_time()
seems like a great candidate, but I have no idea what units it returns on a Mac, can't seem to find a straight answer, and I need to convert to nanoseconds. I tried time.time() and the answer seemed wildly wrong. Thoughts on what I can do here?