Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(jsx): skip the special behavior when the element is in the head. #3352

Merged
merged 1 commit into from
Sep 1, 2024

Conversation

usualoma
Copy link
Member

@usualoma usualoma commented Sep 1, 2024

#3347

The following elements are no longer special behavior when they are already in the head element.

  • title
  • meta
  • script

In my environment, the results were as follows

benchmark        time (avg)             (min … max)       p75       p99      p999
--------------------------------------------------- -----------------------------
• Real World Scenario
--------------------------------------------------- -----------------------------
KitaJS/Html     426 µs/iter     (352 µs … 1'410 µs)    384 µs    856 µs  1'015 µs
Typed Html    1'644 µs/iter   (1'477 µs … 2'078 µs)  1'751 µs  1'960 µs  2'078 µs
VHtml         2'184 µs/iter   (2'051 µs … 2'730 µs)  2'248 µs  2'655 µs  2'730 µs
React JSX     5'673 µs/iter   (5'406 µs … 6'461 µs)  5'898 µs  6'422 µs  6'461 µs
Preact          793 µs/iter     (625 µs … 2'217 µs)    697 µs  1'750 µs  2'217 µs
React         5'645 µs/iter   (5'407 µs … 6'361 µs)  5'844 µs  6'331 µs  6'361 µs
Common Tags   2'941 µs/iter   (2'783 µs … 3'680 µs)  2'947 µs  3'589 µs  3'680 µs
Ghtml           201 µs/iter     (165 µs … 1'266 µs)    188 µs    910 µs  1'195 µs
JSXTE         3'686 µs/iter   (3'261 µs … 4'513 µs)  3'766 µs  4'314 µs  4'513 µs
hono/jsx      1'046 µs/iter   (1'002 µs … 1'231 µs)  1'060 µs  1'203 µs  1'231 µs

summary for Real World Scenario
  Ghtml
   2.12x faster than KitaJS/Html
   3.94x faster than Preact
   5.19x faster than hono/jsx
   8.16x faster than Typed Html
   10.84x faster than VHtml
   14.6x faster than Common Tags
   18.3x faster than JSXTE
   28.03x faster than React
   28.17x faster than React JSX

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

Copy link

codecov bot commented Sep 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (040b0d4) to head (f073f53).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3352      +/-   ##
==========================================
- Coverage   95.76%   95.76%   -0.01%     
==========================================
  Files         151      151              
  Lines        9166     9186      +20     
  Branches     2683     2692       +9     
==========================================
+ Hits         8778     8797      +19     
- Misses        388      389       +1     

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

@yusukebe
Copy link
Member

yusukebe commented Sep 1, 2024

Hey @usualoma

The following elements are no longer special behavior when they are already in the head element.

That's a good improvement.

My score is below. Looks good!

cpu: Apple M1 Pro
runtime: node v22.6.0 (arm64-darwin)

benchmark        time (avg)             (min … max)       p75       p99      p999
--------------------------------------------------- -----------------------------
• Real World Scenario
--------------------------------------------------- -----------------------------
KitaJS/Html     483 µs/iter     (389 µs … 1'167 µs)    420 µs  1'044 µs  1'137 µs
Typed Html    1'791 µs/iter   (1'573 µs … 2'239 µs)  2'046 µs  2'200 µs  2'239 µs
VHtml         2'182 µs/iter   (2'045 µs … 2'770 µs)  2'257 µs  2'733 µs  2'770 µs
React JSX     5'994 µs/iter   (5'551 µs … 6'866 µs)  6'437 µs  6'866 µs  6'866 µs
Preact          970 µs/iter     (656 µs … 4'845 µs)    892 µs  2'825 µs  4'845 µs
React         6'203 µs/iter  (5'647 µs … 11'046 µs)  6'681 µs 11'046 µs 11'046 µs
Common Tags   2'965 µs/iter   (2'762 µs … 3'621 µs)  2'890 µs  3'583 µs  3'621 µs
Ghtml           221 µs/iter     (170 µs … 1'620 µs)    208 µs  1'180 µs  1'499 µs
JSXTE         3'869 µs/iter   (3'745 µs … 4'091 µs)  3'902 µs  4'076 µs  4'091 µs
hono/jsx      1'075 µs/iter     (959 µs … 1'867 µs)  1'003 µs  1'779 µs  1'867 µs

summary for Real World Scenario
  Ghtml
   2.19x faster than KitaJS/Html
   4.39x faster than Preact
   4.87x faster than hono/jsx
   8.11x faster than Typed Html
   9.87x faster than VHtml
   13.42x faster than Common Tags
   17.51x faster than JSXTE
   27.13x faster than React JSX
   28.07x faster than React

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe yusukebe merged commit e4cc5aa into honojs:main Sep 1, 2024
14 checks passed
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