Skip to content

Commit ef90895

Browse files
committed
add benchmark scripts
1 parent 71c0097 commit ef90895

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

benchmarks/bench_city.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# Note: this benchamr script is based on a similar one for xxHash:
4+
# https://github.com/ifduyue/python-xxhash
5+
6+
PYTHON=${PYTHON-`which python`}
7+
8+
echo Benchmarking CityHash...
9+
10+
echo -n " 64WithSeed 1000B: "
11+
$PYTHON -mtimeit -s 'from cityhash import CityHash64WithSeed as hasher' \
12+
-s 'import os' \
13+
-s 'import random' \
14+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
15+
-s 'data = os.urandom(1000)' \
16+
'hasher(data, seed=seed)'
17+
18+
echo -n " 64WithSeed 10000B: "
19+
$PYTHON -mtimeit -s 'from cityhash import CityHash64WithSeed as hasher' \
20+
-s 'import os' \
21+
-s 'import random' \
22+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
23+
-s 'data = os.urandom(10000)' \
24+
'hasher(data, seed=seed)'
25+
26+
echo -n " 128WithSeed 1000B: "
27+
$PYTHON -mtimeit -s 'from cityhash import CityHash128WithSeed as hasher' \
28+
-s 'import os' \
29+
-s 'import random' \
30+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
31+
-s 'data = os.urandom(1000)' \
32+
'hasher(data, seed=seed)'
33+
34+
echo -n " 128WithSeed 10000B: "
35+
$PYTHON -mtimeit -s 'from cityhash import CityHash128WithSeed as hasher' \
36+
-s 'import os' \
37+
-s 'import random' \
38+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
39+
-s 'data = os.urandom(10000)' \
40+
'hasher(data, seed=seed)'
41+
42+
echo -n " Crc128WithSeed 1000B: "
43+
$PYTHON -mtimeit -s 'from cityhashcrc import CityHashCrc128WithSeed as hasher' \
44+
-s 'import os' \
45+
-s 'import random' \
46+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
47+
-s 'data = os.urandom(1000)' \
48+
'hasher(data, seed=seed)'
49+
50+
echo -n " Crc128WithSeed 10000B: "
51+
$PYTHON -mtimeit -s 'from cityhashcrc import CityHashCrc128WithSeed as hasher' \
52+
-s 'import os' \
53+
-s 'import random' \
54+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
55+
-s 'data = os.urandom(10000)' \
56+
'hasher(data, seed=seed)'

benchmarks/bench_farm.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
# Note: this benchamr script is based on a similar one for xxHash:
4+
# https://github.com/ifduyue/python-xxhash
5+
6+
PYTHON=${PYTHON-`which python`}
7+
8+
echo Benchmarking FarmHash...
9+
10+
echo -n " 32WithSeed 1000B: "
11+
$PYTHON -mtimeit -s 'from farmhash import FarmHash32WithSeed as hasher' \
12+
-s 'import os' \
13+
-s 'import random' \
14+
-s 'seed = random.randint(0, 0xffffffff)' \
15+
-s 'data = os.urandom(1000)' \
16+
'hasher(data, seed=seed)'
17+
18+
echo -n " 32WithSeed 10000B: "
19+
$PYTHON -mtimeit -s 'from farmhash import FarmHash32WithSeed as hasher' \
20+
-s 'import os' \
21+
-s 'import random' \
22+
-s 'seed = random.randint(0, 0xffffffff)' \
23+
-s 'data = os.urandom(10000)' \
24+
'hasher(data, seed=seed)'
25+
26+
echo -n " 64WithSeed 1000B: "
27+
$PYTHON -mtimeit -s 'from farmhash import FarmHash64WithSeed as hasher' \
28+
-s 'import os' \
29+
-s 'import random' \
30+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
31+
-s 'data = os.urandom(1000)' \
32+
'hasher(data, seed=seed)'
33+
34+
echo -n " 64WithSeed 10000B: "
35+
$PYTHON -mtimeit -s 'from farmhash import FarmHash64WithSeed as hasher' \
36+
-s 'import os' \
37+
-s 'import random' \
38+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
39+
-s 'data = os.urandom(10000)' \
40+
'hasher(data, seed=seed)'
41+
42+
43+
echo -n " 128WithSeed 1000B: "
44+
$PYTHON -mtimeit -s 'from farmhash import FarmHash128WithSeed as hasher' \
45+
-s 'import os' \
46+
-s 'import random' \
47+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
48+
-s 'data = os.urandom(1000)' \
49+
'hasher(data, seed=seed)'
50+
51+
echo -n " 128WithSeed 10000B: "
52+
$PYTHON -mtimeit -s 'from farmhash import FarmHash128WithSeed as hasher' \
53+
-s 'import os' \
54+
-s 'import random' \
55+
-s 'seed = random.randint(0, 0xffffffffffffffff)' \
56+
-s 'data = os.urandom(10000)' \
57+
'hasher(data, seed=seed)'

0 commit comments

Comments
 (0)