Skip to content

Instantly share code, notes, and snippets.

@KrzysztofCiba
Last active December 18, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrzysztofCiba/5717137 to your computer and use it in GitHub Desktop.
Save KrzysztofCiba/5717137 to your computer and use it in GitHub Desktop.
popcnt benchmarks
# --- testBK.py
import sys
import random
from popcnt import popcntBK
up = 2**256
for i in range(1, 1001):
if not i % 10:
print ".",
sys.stdout.flush()
if not i % 100:
print
sys.stdout.flush()
for j in range(1000):
popcntBK( random.randint( 0, up ) )
# --- testLUT.py
import sys
import random
from popcnt import popcntLUT
up = 2**256
for i in range(1, 1001):
if not i % 10:
print ".",
sys.stdout.flush()
if not i % 100:
print
sys.stdout.flush()
for j in range(1000):
popcntLUT( random.randint( 0, up ) )
# --- testNaive.py
import sys
import random
from popcnt import popcntNaive
up = 2**256
for i in range(1, 1001):
if not i % 10:
print ".",
sys.stdout.flush()
if not i % 100:
print
sys.stdout.flush()
for j in range(1000):
popcntNaive( random.randint( 0, up ) )
# --- testUgly.py
import sys
import random
from popcnt import popcntUgly
up = 2**256
for i in range(1, 1001):
if not i % 10:
print ".",
sys.stdout.flush()
if not i % 100:
print
sys.stdout.flush()
for j in range(1000):
popcntUgly( random.randint( 0, up ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment