Benchmark value slice, update function#261
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
a523875 to
9fa784b
Compare
|
After more consideration I decided to just stick with the So I guess in the end the code ended up being the same as @Ayoub-Mabrouk, but it includes benchmarks and package size checks. |
| "size": "size-limit", | ||
| "specs": "ts-scripts specs", | ||
| "test": "ts-scripts test" | ||
| "test": "ts-scripts test && npm run size" |
There was a problem hiding this comment.
Do you intend to keep this or was it for debugging?
There was a problem hiding this comment.
Ah I see in your comment that it is intentionally added
Related to #259, I did end up running a bunch of tests and it's fairly inconclusive overall. So the other thing I hoped was another approach might compress smaller, but that turned out to be untrue too. However, I did incorporate a change into the code as a result of these experiments based on node (V8) + bun (WebKit) performance. Benchmarks:
Node:
Bun:
Results change each run, but two things seem clear:
whileloopsI didn't expect both these things to be true, so the implementation change in this PR feels like the "best" outcome of the performance testing. It's consistently one of the top results, and logically it makes sense - the real world usage will typically either be it's completely empty (
'') or it's a cookie with some values and no whitespace. Which means it would be the minimum number of checks in both cases. The only case it would result in more checks is when the text is only whitespace (e.g.' ').