Skip to content

Use character map for performance - #146

Open
blakeembrey wants to merge 1 commit into
masterfrom
be/perf
Open

blakeembrey wants to merge 1 commit into
masterfrom
be/perf

Conversation

@blakeembrey

Copy link
Copy Markdown
Member

Pulls over the same optimizations made in https://github.com/jshttp/content-type/releases/tag/v3.1.0

Implemented using Codex and used content-type as reference, since both repos are similarly shaped.

  name                                             before (hz)      after (hz)

  create
    create()                                     15,263,523.77   16,588,735.64
    create(filename)                              5,736,369.95    6,356,232.70

  parse
    long token parameter                          1,413,574.33    4,120,098.06
    type                                         13,572,052.34   15,874,781.78
    uppercase type and parameter                  5,677,821.82    5,819,704.36
    token parameter                               5,593,482.60    6,396,541.68
    header                                        5,049,389.33    6,635,121.04
    header with escaped quotes                    4,025,914.66    4,523,156.70
    header with UTF-8 extended parameter           2,303,154.19    2,543,941.40
    header with multipart enabled                 3,988,697.23    3,980,823.05

  decodeExtended
    latin1 with long literal tail                   644,728.62    7,670,947.37
    latin1 with dense escapes                       437,210.80      805,460.75
    latin1 without escapes                       10,807,353.46   10,693,545.25
    latin1 with invalid encoding                  7,682,645.15    9,258,493.46
    value                                         4,540,728.57    4,729,488.77
    value with invalid encoding                     338,508.60      346,519.06
    value with latin1 encoding                     3,170,065.61    5,421,457.51

  encodeExtended
    filename                                      5,290,168.64    5,217,143.46

  format
    token                                         7,417,107.30    7,854,985.43
    token multipart                               5,659,159.07    6,922,231.31
    quoted                                        4,201,189.10    6,810,183.69
    quoted multipart                              5,798,361.80    7,338,839.30
    escaped                                       2,783,446.51    4,994,457.36
    escaped multipart                             3,668,536.28    4,843,441.99
    latin1                                        4,273,128.76    6,967,374.48
    latin1 multipart                              5,640,998.14    7,245,018.58
    extended                                      2,962,914.22    3,248,181.93
    extended multipart                            4,711,085.53    5,929,380.93
    longToken                                     3,284,089.88    1,292,430.09
    longToken multipart                           5,628,397.63    7,114,854.78
    longQuoted                                      816,632.72    1,228,886.48
    longQuoted multipart                          5,439,130.67    6,871,159.24

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #146   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          213       278   +65     
  Branches        58        77   +19     
=========================================
+ Hits           213       278   +65     

☔ View full report in Codecov by Harness.
📢 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.

2 participants