Giter VIP home page Giter VIP logo

bench_hash_functions's Introduction

Benchmark hash functions

A simple benchmark to test the speed of some popular hash functions, such as MurmurHash, CityHash, and SpookyHash.

The hashers in include/hashers.hpp are basically wrappers of the methods exposed by the SMHasher test suite.

Get and Compile the code

git clone --recursive https://github.com/jermp/bench_hash_functions.git
cd bench_hash_functions
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Run the benchmark

Run the perf executable. Some examples below.

  • Example 1

      ./perf 10000000
    

    will test all hashers on 10M random 64-bit keys.

  • Example 2

      ./perf 10000000 --input ~/Desktop/uk-2005.urls --hasher cityhash_64
    

    will test the hasher cityhash_64 on 10M strings from the file ~/Desktop/uk-2005.urls.

Results

Here are some results I collected on an Intel i9-9900K core (@3.60 GHz), running Linux 5. I used gcc 9.3.0 with all optimizations.

I measured the time it takes to compute the hash function. Results are in average nanoseconds per key.

As input data, I used 100M keys: 64-bit keys, and strings from the GoogleBooks corpus (average string length respectively equal to 13.97 and 19.06 for 2- and 3-grams.)

The suffix _64 and _128 indicates 64-bit and 128-bit hashes respectively.

Hasher 64-bit keys GoogleBooks 2-grams GoogleBooks 3-grams
murmurhash2_64 2.80 8.10 9.48
murmurhash3_128 9.98 14.21 15.09
cityhash_64 2.97 5.08 5.51
cityhash_128 6.29 8.98 9.81
spookyhash_64 5.75 11.17 12.97
spookyhash_128 5.73 11.33 13.15

From these results, cityhash is the clear winner.

bench_hash_functions's People

Contributors

jermp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.