Correct way to use timeit and why its giving me wrong incorrect timings

i m not understanding the correct way to use timeit and should i measure performance with timeit rather than big(O)s ?
the main confusion i have is is timeit module used to test time like this ?
how i m using it : View paste 27ZA
output :
```

normal function : 0.22281252100037818
normal function but without using negative slicing in range: 0.3739022379995731
method : 0.012264596998647903
slicing : 0.05156217699914123
twopointer : 0.1798148059988307
normal function : 1.5392431849995774
normal function but without using negative slicing in range: 3.0297319750006864
method : 0.02925749799942423
slicing : 0.12812948800092272
twopointer : 1.4394109820004815
normal function : 17.955775120000908
normal function but without using negative slicing in range: 46.29716704200109
method : 0.2414095370004361
slicing : 1.1492243480006437
twopointer : 19.408573606000573

```
also i have this confusion that :

why sometimes 100+200; 100-200 is taking less time than 100+200 ? and why sometimes 100 + 200 takes on average 4.18 nsec while 100+200; 100-200 takes 4.16nsec i expect 100+200;100-200 to take twice as much time as 100+200

Big O notation tells you how something scales. It tells you nothing about how fast or slow it actually is, only how that time requirement goes up as the thing you’re doing gets bigger. To understand what’s happening, you really need to run multiple tests, which you can do with timeit.repeat, or (my preferred method) python3 -m timeit, as you used in your second example.

On that subject:

You’re testing pure noise here. There is actually nothing going on. I think you’ll do better here to explore the code with the dis module rather than playing with timings, but so long as you’re looking at timings, read the scale: this is single-digit nanoseconds, and they’re all basically the same value. What you can learn from this is that there’s no statistically significant difference between them, and no notable amoutn of time being spent at all.

(HINT: What you’re seeing here is called “constant folding”. Poke around with dis.dis() to see a bit more of what Python’s actually doing here.)

What “incorrect timings” (of your larger script)? What issue are we supposed to see in all that output?

I don’t see a problem in your timing code so I think it’s okay.

Are you having problem understanding the output or something?

I suggest for an effective use of timeit to use autorange, so you can get a reasonable number to use with repeat.