Skip to content

Conversation

@zsilbi
Copy link
Collaborator

@zsilbi zsilbi commented Mar 7, 2025

Improvements

This is a potentially breaking change (in output) which affects the:

  • Map
  • Set
  • and all other object key/value order.

For the sorting and comparison we should use the fastest possible way to achieve stable output.
Using localeCompare() is unnecessary and slower than regular comparison.

compare() can be improved even further by handling equality and type differences first.

  test/benchmarks.bench.ts > benchmarks > serialize - presets > count:128, size:large (with 3000 items in the Set) 1221ms
     name             hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · ohash @ v3   607.10  1.4323  3.5234  1.6472  1.6063  2.7927  3.4553  3.5234  ±2.39%      304
   · ohash @ dev  851.29  1.0530  3.0835  1.1747  1.1283  2.0994  2.2536  3.0835  ±1.83%      426   fastest

 BENCH  Summary

  ohash @ dev - test/benchmarks.bench.ts > benchmarks > serialize - presets > count:128, size:large
    1.40x faster than ohash @ v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants