|
| 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)' |
0 commit comments