Giter Club home page Giter Club logo

Comments (5)

KilianB avatar KilianB commented on August 28, 2024

for smaller than 64 bit hashes we could also fall back to long variables and do primitive bit shifting.

from jimagehash.

KilianB avatar KilianB commented on August 28, 2024

jmh benchmarks.
Big Integer is the current implementation. Performance decreases with increased hash length

BenchmarkModeCntScoreErrorUnits
kilianB.HashCreationBenchmark.benchmarkAverageHash32BigIntegerthrpt25152626,545± 2741,163ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash32BigIntegerStringBuilderthrpt25158690,519± 2111,147ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash32MutableBigIntegerthrpt25157546,217± 2026,677ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash128BigIntegerthrpt25104932,391± 1387,338ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash128BigIntegerStringBuilderthrpt25117392,216± 1035,051ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash128MutableBigIntegerthrpt25116409,836± 2436,276ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash5000BigIntegerthrpt251387,469± 6,534ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash5000BigIntegerStringBuilderthrpt257690,280± 96,870 ops/s
kilianB.HashCreationBenchmark.benchmarkAverageHash5000MutableBigIntegerthrpt257715,949± 49,220ops/s

Mutable big integer requires method handles and reflection access which is not warranted for the performance difference compare to the stringbuilder approach (as well as unit tests to guarantee that the implementation is working as expected).

A new StringBuilder is created for every hash creation. Caching a stringbuilder would result again in a performance gain at the cost of thread safety. In relation file IO is much more heavy and the treadoff isn't worth it.

Migration to either stringbuilder or mutable big int allows to cut the first pass needed to estimate the hash length on an algorithm basis

from jimagehash.

KilianB avatar KilianB commented on August 28, 2024

fixed with afc026d

from jimagehash.

KilianB avatar KilianB commented on August 28, 2024

Using a custom hash builder which manipulates a byte array directly we can gain even more performance d9ef1f8
Now even the 5000 bit hash runs with 13.000 hashes created / second up from 1.3 k

from jimagehash.

KilianB avatar KilianB commented on August 28, 2024

fixed with v 3.0.0

from jimagehash.

Related Issues (20)

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.