Skip to content

Improve perf with benchmarks#54

Merged
blakeembrey merged 3 commits into
masterfrom
be/bench
May 14, 2026
Merged

Improve perf with benchmarks#54
blakeembrey merged 3 commits into
masterfrom
be/bench

Conversation

@blakeembrey

Copy link
Copy Markdown
Member

Not a huge difference but I think there's minor improvements from switching to .test without any capturing groups and doing an indexOf. Doing an indexOf first, splitting, and doing two regexes was worse performance so keeping the combined regex.

Before:

 ✓ src/index.bench.ts > typer.format 5205ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic type        15,977,178.63  0.0000  0.0468  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.08%  7988590
   · type with suffix  13,237,552.41  0.0000  0.0331  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.05%  6618777

 ✓ src/index.bench.ts > typer.parse 5273ms
     name                                    hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic type                   10,342,529.59  0.0000  0.2653  0.0001  0.0001  0.0001  0.0001  0.0003  ±0.62%  5171265
   · type with suffix              8,934,931.50  0.0000  0.2490  0.0001  0.0001  0.0001  0.0002  0.0005  ±0.35%  4467466
   · upper-case type with suffix   8,639,883.98  0.0000  0.2628  0.0001  0.0001  0.0001  0.0002  0.0005  ±0.43%  4319942

 ✓ src/index.bench.ts > typer.test 7375ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic type        16,299,085.64  0.0000  0.2822  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.13%  8149543
   · type with suffix  14,299,089.91  0.0000  0.0716  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.09%  7149546
   · invalid type      11,035,720.85  0.0000  0.0488  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.05%  5517861

After:

 ✓ src/index.bench.ts > typer.format 5157ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic type        16,036,027.33  0.0000  0.1687  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.13%  8018014
   · type with suffix  12,971,083.09  0.0000  0.0478  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.08%  6485542

 ✓ src/index.bench.ts > typer.parse 5788ms
     name                                    hz     min      max    mean     p75     p99    p995    p999     rme  samples
   · basic type                   11,047,909.29  0.0000   0.4069  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.57%  5523955
   · type with suffix              9,894,087.39  0.0000  14.7271  0.0001  0.0001  0.0001  0.0001  0.0002  ±5.84%  4947044
   · upper-case type with suffix  10,207,665.14  0.0000   0.2047  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.36%  5103833

 ✓ src/index.bench.ts > typer.test 8161ms
     name                         hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · basic type        18,896,733.21  0.0000  0.0299  0.0001  0.0001  0.0001  0.0001  0.0001  ±0.05%  9448367
   · type with suffix  16,784,829.36  0.0000  0.0665  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.07%  8392415
   · invalid type      13,560,077.97  0.0000  2.6157  0.0001  0.0001  0.0002  0.0002  0.0002  ±1.31%  6780039

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #54   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           56        39   -17     
  Branches        23        15    -8     
=========================================
- Hits            56        39   -17     

☔ 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.

Comment thread src/index.ts
* DIGIT = %x30-39 ; 0-9
*/
const subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/;
const subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Noticed we allow multiple + in the typeRegExp but not when building it which breaks the ability to round trip. The RFC also allows multiple +.

@blakeembrey blakeembrey merged commit ea556f4 into master May 14, 2026
9 checks passed
@blakeembrey blakeembrey deleted the be/bench branch May 14, 2026 23:43
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