Coder Social home page Coder Social logo

digest-murmurhash's Introduction

Digest::MurmurHash

Build Status

MurmurHash is a algorithm desiged by Austin Appleby.

This library have some classes for MurmurHash algorithm.

  • Digest::MurmurHash1 use algorithm MurmurHash1(32-bit).

  • Digest::MurmurHash2 use algorithm MurmurHash2(32-bit).

  • Digest::MurmurHash2A use algorithm MurmurHash2A(32-bit).

  • Digest::MurmurHash64A use algorithm MurmurHash64A(64-bit).

  • Digest::MurmurHash64B use algorithm MurmurHash64B(64-bit).

  • Digest::MurmurHashNeutral2 use algorithm MurmurHashNeutral2(32-bit).

  • Digest::MurmurHashAligned2 use algorithm MurmurHashAligned2(32-bit).

  • Digest::MurmurHash3_x86_32 use algorithm MurmurHash3 for 32-bit platform (32-bit).

  • Digest::MurmurHash3_x86_128 use algorithm MurmurHash3 for 32-bit platform (128-bit).

  • Digest::MurmurHash3_x64_128 use algorithm MurmurHash3 for 64-bit platform (128-bit).

(Digest::MurmurHash class was nothing)

All classes compliance Digest API of Ruby.

Usage

require 'digest/murmurhash'

# MurmurHash1 can use like same than Digest::XXX.

p Digest::MurmurHash1.hexdigest('murmurhash') #=> d5ab09c7
p Digest::MurmurHash1.digest('murmurhash') #=> \xD5\xAB\x09\xC7
p Digest::MurmurHash1.file("./LICENSE.txt").hexdigest #=> "41962e71"

# Original method for performance
p Digest::MurmurHash1.rawdigest('murmurhash') #=> 3339299797

Feature

  • Very fast because hash algorithm is written by C extention
  • You can try all Hurmurhash algorithms
  • You can use same interface built-in Digest::{MD5,SH1,...} classes because each class inherited Digest::Class.

Benchmark

call Digest::XXX.digest (see also spec/bench.rb)

$ bundle exec ruby spec/bench.rb
### condition

    RUBY_VERSION = 2.6.5
    count = 1000
    data size = 100 KB

### benchmark

MurmurHash1	0.04397099930793047
MurmurHash2	0.030599999241530895
MurmurHash2A	0.03052499983459711
MurmurHash64A	0.014573999680578709
MurmurHash64B	0.027068999595940113
MurmurHashNeutral2	0.028548000380396843
MurmurHashAligned2	0.03340199962258339
MurmurHash3_x86_32	0.08531500026583672
MurmurHash3_x86_128	0.10534099955111742
MurmurHash3_x64_128	0.05008100066334009
Digest::MD5	0.1293069999665022
Digest::SHA1	0.10616999957710505
Digest::SHA256	0.23746399953961372
Digest::SHA2	0.23401100002229214
OpenSSL::HMAC(sha256)	0.23477800004184246
Base64	0.1534709995612502
Zlib.crc32	0.008456000126898289

image

Installation

Add this line to your application's Gemfile:

gem 'digest-murmurhash'

And then execute:

$ bundle

Or install it yourself as:

$ gem install digest-murmurhash

License

See the file LICENSE.txt.

See also

https://sites.google.com/site/murmurhash/

digest-murmurhash's People

Contributors

ksss 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.