Skip to content

Instantly share code, notes, and snippets.

@smarnach
Created February 15, 2012 22:09
Show Gist options
  • Save smarnach/1839351 to your computer and use it in GitHub Desktop.
Save smarnach/1839351 to your computer and use it in GitHub Desktop.
Tmimings on a Linux box, 32-bit kernel, 32-bit userland
Python version: 2.7 3.1
-s"a=10**20;n=3" "(a>>n)&1" 0.224 usec per loop 0.161 usec per loop
-s"a=10**20;n=3" "not not(a & (1 << n))" 0.155 usec per loop 0.183 usec per loop
-s"a=10**200;n=3" "(a>>n)&1" 0.39 usec per loop 0.303 usec per loop
-s"a=10**200;n=3" "not not(a & (1 << n))" 0.158 usec per loop 0.177 usec per loop
-s"a=10**10;n=3" "(a>>n)&1" 0.223 usec per loop 0.153 usec per loop
-s"a=10**10;n=3" "not not(a & (1 << n))" 0.158 usec per loop 0.18 usec per loop
-s"a=10**9;n=3" "(a>>n)&1" 0.0734 usec per loop 0.152 usec per loop
-s"a=10**9;n=3" "not not(a & (1 << n))" 0.0877 usec per loop 0.178 usec per loop
-s"a=2**1000;n=64" "(a>>n)&1" 0.442 usec per loop 0.363 usec per loop
-s"a=2**1000;n=64" "not not(a & (1 << n))" 0.241 usec per loop 0.187 usec per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment