Closed blakeembrey closed 1 month ago
Using a loop to find =
adds another small bump (in most cases):
> /Users/blakeembrey/.n/bin/node benchmark/parse-top.js
cookie.parse - top sites
14 tests completed.
parse accounts.google.com x 12,036,730 ops/sec ±0.39% (193 runs sampled)
parse apple.com x 14,565,865 ops/sec ±0.38% (196 runs sampled)
parse cloudflare.com x 11,998,435 ops/sec ±0.36% (195 runs sampled)
parse docs.google.com x 11,210,175 ops/sec ±0.19% (196 runs sampled)
parse drive.google.com x 11,201,061 ops/sec ±0.23% (196 runs sampled)
parse en.wikipedia.org x 2,125,988 ops/sec ±0.26% (194 runs sampled)
parse linkedin.com x 2,512,798 ops/sec ±0.21% (195 runs sampled)
parse maps.google.com x 6,320,705 ops/sec ±0.26% (195 runs sampled)
parse microsoft.com x 4,206,180 ops/sec ±0.23% (195 runs sampled)
parse play.google.com x 12,477,047 ops/sec ±1.11% (190 runs sampled)
parse support.google.com x 7,708,796 ops/sec ±0.38% (193 runs sampled)
parse www.google.com x 4,982,141 ops/sec ±0.39% (196 runs sampled)
parse youtu.be x 2,134,174 ops/sec ±0.21% (196 runs sampled)
parse youtube.com x 2,138,205 ops/sec ±0.25% (196 runs sampled)
> /Users/blakeembrey/.n/bin/node benchmark/parse.js
cookie.parse - generic
6 tests completed.
simple x 16,037,488 ops/sec ±0.61% (193 runs sampled)
decode x 5,224,018 ops/sec ±0.39% (195 runs sampled)
unquote x 14,508,555 ops/sec ±0.43% (197 runs sampled)
duplicates x 3,992,515 ops/sec ±0.42% (195 runs sampled)
10 cookies x 1,159,203 ops/sec ±0.26% (196 runs sampled)
100 cookies x 81,236 ops/sec ±0.54% (193 runs sampled)
Undid the =
loop for now since perf falls behind after ~10 characters, so it'd be a matter of deciding whether most cookie names are < 10 characters or not to adopt that change.
Uses a loop over spaces instead of
.trim()
. Appears to be a reasonable perf improvement in testing.Before:
After: