Skip to content

Faster stringify cookie with benchmarks#262

Open
blakeembrey wants to merge 1 commit intomasterfrom
be/perf-stringify-cookie
Open

Faster stringify cookie with benchmarks#262
blakeembrey wants to merge 1 commit intomasterfrom
be/perf-stringify-cookie

Conversation

@blakeembrey
Copy link
Member

I decided to try investigating if anything in #250 holds true, and found the opposite for string concatenation. Updated to use string concatenation to improve performance.

Before:

 ✓ src/stringify-cookie.bench.ts > cookie.stringifyCookie 7195ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · empty             19,138,902.74  0.0000  0.0572  0.0001  0.0000  0.0001  0.0001  0.0002  ±0.11%  9569452
   · simple             5,777,350.07  0.0001  0.3515  0.0002  0.0002  0.0002  0.0003  0.0006  ±0.39%  2888676
   · undefined values   3,129,664.63  0.0002  0.3241  0.0003  0.0003  0.0004  0.0004  0.0008  ±0.46%  1564833
   · 10 cookies           765,737.48  0.0012  0.4257  0.0013  0.0013  0.0014  0.0016  0.0020  ±0.34%   382869
   · 100 cookies           78,240.71  0.0122  0.4788  0.0128  0.0128  0.0137  0.0160  0.0424  ±0.39%    39121

After:

 ✓ src/stringify-cookie.bench.ts > cookie.stringifyCookie 7958ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme   samples
   · empty             21,654,747.61  0.0000  0.1649  0.0000  0.0000  0.0001  0.0001  0.0002  ±0.14%  10827374
   · simple             7,345,985.72  0.0000  0.0540  0.0001  0.0001  0.0002  0.0002  0.0003  ±0.10%   3672994
   · undefined values   3,820,139.53  0.0002  0.0491  0.0003  0.0003  0.0003  0.0004  0.0004  ±0.11%   1910070
   · 10 cookies           854,240.43  0.0010  0.4322  0.0012  0.0012  0.0013  0.0014  0.0019  ±0.44%    427121
   · 100 cookies           85,417.71  0.0110  0.4168  0.0117  0.0117  0.0126  0.0160  0.0470  ±0.44%     42709

Copy link
Member

@sheplu sheplu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a change for the folder that should host the two new bench files
Other than than LGTM!

@@ -0,0 +1,41 @@
import { describe, bench } from "vitest";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would that make more sense to move the two new bench.ts file in the benchmark folder already existing?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants