Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly are fractional seconds returned by Python time.perf_counter()?

This is probably a dumb/obvious question, but just want to make sure my hunches are correct.

I'm doing some basic performance timing in a Python3 script using time.perf_counter() like so:

start = time.perf_counter()
# some time consuming operation here
end = time.perf_counter()
elapsed = end - start

And I'll get back values like 9.774 or 36.903 (to many more decimal places, of course). I'm assuming that larger numbers = more time elapsed, but what exactly do these numbers mean? E.g. is 1.23 fractional seconds just 1 second and .23 fractions of a second

like image 821
baisang Avatar asked Aug 05 '15 15:08

baisang


1 Answers

As far as I know, "fractional second" just means a second with a fractional part (as opposed to a strictly integer number of seconds). So 9.774 means 9 seconds plus 774/1000 seconds.

like image 157
ezig Avatar answered Oct 16 '22 23:10

ezig