Skip to content

Benchmark parse function#96

Open
blakeembrey wants to merge 2 commits intomasterfrom
be/benchmark-parse
Open

Benchmark parse function#96
blakeembrey wants to merge 2 commits intomasterfrom
be/benchmark-parse

Conversation

@blakeembrey
Copy link
Copy Markdown
Member

Add a benchmark utility, remove user:pass regex in favor of simple indexOf. Somewhat faster.

Before:

     name                                                hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic auth header                         2,051,649.51  0.0003  1.5729  0.0005  0.0004  0.0012  0.0014  0.0141  ±1.34%  1025825
   · basic auth header with extra whitespace   2,353,509.46  0.0003  0.2861  0.0004  0.0004  0.0005  0.0006  0.0016  ±0.32%  1176755
   · invalid basic auth header                 2,470,888.19  0.0002  0.4685  0.0004  0.0004  0.0005  0.0011  0.0025  ±0.63%  1235445
   · non-basic auth header                    17,442,921.02  0.0000  0.4710  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.34%  8721461

After:

 ✓ src/parse.bench.ts > parse 6339ms
     name                                                hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic auth header                         2,386,295.98  0.0003  0.6112  0.0004  0.0004  0.0011  0.0011  0.0021  ±0.64%  1193148
   · basic auth header with extra whitespace   2,426,362.48  0.0003  0.3008  0.0004  0.0004  0.0005  0.0005  0.0011  ±0.30%  1213182
   · invalid basic auth header                 2,667,422.31  0.0002  0.2500  0.0004  0.0004  0.0005  0.0005  0.0010  ±0.27%  1333712
   · non-basic auth header                    16,981,965.93  0.0000  2.4181  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.97%  8490983

I also made an attempt with a parser similar to cookie, content-type, etc but the perf gains vs complexity/code overhead doesn't seem to be worth it, the indexOf is pretty small in comparison.

@blakeembrey blakeembrey requested a review from Phillip9587 April 7, 2026 22:00
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ee70132) to head (a6089af).

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #96   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           48        47    -1     
  Branches        21        19    -2     
=========================================
- Hits            48        47    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant