Giter VIP home page Giter VIP logo

murmurhash.net's Introduction

MurmurHash.Net

NuGet Build Status License

Extremely fast MurmurHash3 implementation with zero heap allocations

This is a fork of the System.Data.HashFunction.MurmurHash.

Differences

  • Faster (zero heap allocations via Spans, reduced class inheritance, bytes to uint conversion optimisations)
  • Only 32-bit output hash value. Maybe 128-bit will be supported in the future. But you can implement it by yourself and send me PR :)

Installation

This project is available as a NuGet package

Example

Some code 1. You can use traditional byte[]

uint hash = MurmurHash3.Hash32(bytes: new byte[]{1,2,3}, seed: 123456U);
Console.WriteLine(hash);

Output 1

3800434721

Some code 2. State-of-the-art Span<byte> and ReadOnlySpan<byte> also supported

ReadOnlySpan<byte> span = ...
uint hash = MurmurHash3.Hash32(bytes: span, seed: 123456U);

Benchmarks

// * Summary *

BenchmarkDotNet=v0.12.0, OS=macOS Mojave 10.14.6 (18G103) [Darwin 18.7.0]
Intel Core i7-7660U CPU 2.50GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.1.100
  [Host]     : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
  DefaultJob : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT

Byte[] to uint

Method Mean StdDev Ratio RatioSD Gen 0 Allocated
CRC32 40.73 us 0.696 us 3.32 0.06 - -
XxHash 197.13 us 10.995 us 15.65 0.62 87.8906 184000 B
MurMurHashByDarrenkopp 51.46 us 3.469 us 4.04 0.16 15.3198 32000 B
Blake2B 91.83 us 3.949 us 7.57 0.41 7.5684 16000 B
MurMurHashNet 12.28 us 0.122 us 1.00 0.00 - -

String to uint

Method Mean StdDev Ratio RatioSD Gen 0 Allocated
CRC32 65.63 us 1.385 us 3.00 0.08 15.2588 32000 B
XxHash 228.36 us 21.086 us 9.52 0.28 103.2715 216000 B
MurMurHashByDarrenkopp 77.14 us 2.490 us 3.53 0.15 30.6396 64000 B
Blake2B 119.69 us 2.443 us 5.46 0.18 22.9492 48000 B
MurMurHashNet 21.91 us 0.364 us 1.00 0.00 - -

Legend

murmurhash.net's People

Contributors

chwarr avatar odinmillion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chwarr

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.