What do `ns` and `us` stand for in `timeit` result?
Asked Answered
C

2

29

I was trying to compare performance of two statements with timeit, and the results are something like:

 100 loops, best of 3: 100 ns per loop
 100 loops, best of 3: 1.96 us per loop

But I don't know what these ns and us stands for, so I don't know which one is faster.

Cobbs answered 5/8, 2012 at 4:35 Comment(0)
S
47

ns stands for nanoseconds. n is the regular SI prefix meaning 10-9. us means microseconds. In SI that would be µs (10-6 seconds) - the u is used because there's not a µ in ASCII, but it does look pretty similar. In your case, that means you're comparing 100×10-9 seconds against 1.96×10-6 seconds - the former is almost 20× faster.

Silvan answered 5/8, 2012 at 4:37 Comment(0)
M
10

Nanoseconds and microseconds... 10-9 and 10-6 respectively.

Merbromin answered 5/8, 2012 at 4:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.