ohash icon indicating copy to clipboard operation
ohash copied to clipboard

perf(serialize): faster function serialization

Open zsilbi opened this issue 9 months ago • 1 comments

This is a potentially breaking change because the output of the serialized function changes.

The whitespace and new lines are stripped from the output with a RegEx which is probably unnecessary.

 ✓ test/benchmarks.bench.ts > benchmarks > serialize - presets > count:128, size:small (with 6 extra functions) 1216ms
     name               hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · ohash @ v3   3,596.81  0.2484  0.9354  0.2780  0.2618  0.6104  0.6354  0.7763  ±1.14%     1799
   · ohash @ dev  5,808.18  0.1608  2.1286  0.1722  0.1681  0.2893  0.3769  0.5255  ±0.94%     2905   fastest

 BENCH  Summary

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

zsilbi avatar Mar 07 '25 00:03 zsilbi

With faster native function check:

 ✓ test/benchmarks.bench.ts > benchmarks > serialize - presets > count:128, size:small (with 6 extra functions) 1820ms
     name                   hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · ohash @ v3       3,589.43  0.2435  1.6586  0.2786  0.2674  0.5101  0.8508  1.0039  ±1.31%     1795   slowest
   · ohash @ b9f9216  5,908.37  0.1517  1.9966  0.1693  0.1633  0.3314  0.3536  0.5464  ±1.00%     2955
   · ohash @ dev      6,329.94  0.1470  0.3874  0.1580  0.1530  0.2940  0.3180  0.3639  ±0.57%     3165   fastest

 BENCH  Summary

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

zsilbi avatar Mar 09 '25 17:03 zsilbi