Last active
December 18, 2015 03:19
-
-
Save KrzysztofCiba/5717137 to your computer and use it in GitHub Desktop.
popcnt benchmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- 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: | |
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: | |
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: | |
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: | |
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