Skip to content

refactor(props): use startsWith instead of char check for event handler checks#5032

Closed
ali-garajian wants to merge 1 commit intopreactjs:mainfrom
ali-garajian:main
Closed

refactor(props): use startsWith instead of char check for event handler checks#5032
ali-garajian wants to merge 1 commit intopreactjs:mainfrom
ali-garajian:main

Conversation

@ali-garajian
Copy link
Contributor

I ran the mentioned benchmark three times and every time startsWith gained a higher score than char check. Am I missing something?

Screenshot 1404-12-03 at 23 27 01 Screenshot 1404-12-03 at 23 28 00 Screenshot 1404-12-03 at 23 30 12

@github-actions
Copy link

github-actions bot commented Feb 22, 2026

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-2.01ms - +7.14ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.01ms - +0.06ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -0% - +2% (-0.22ms - +1.46ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +4% (-0.26ms - +0.72ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.73ms - +0.65ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -6% - +2% (-0.12ms - +0.03ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.26ms - +0.28ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -2% - +4% (-0.73ms - +1.29ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -7% - +7% (-0.43ms - +0.46ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -2% - +2% (-0.02ms - +0.02ms)
    preact-local vs preact-main
  • todo: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main

Results

create10k
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local801.32ms - 808.08ms-unsure 🔍
-0% - +1%
-2.01ms - +7.14ms
preact-main799.05ms - 805.22msunsure 🔍
-1% - +0%
-7.14ms - +2.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.04ms - 19.04ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main19.04ms - 19.04msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
filter-list
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.51ms - 16.56ms-unsure 🔍
-0% - +0%
-0.01ms - +0.06ms
preact-main16.49ms - 16.54msunsure 🔍
-0% - +0%
-0.06ms - +0.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.54ms - 1.55ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.54ms - 1.55msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k
  • Browser: chrome-headless
  • Sample size: 90
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local59.13ms - 60.39ms-unsure 🔍
-0% - +2%
-0.22ms - +1.46ms
preact-main58.59ms - 59.69msunsure 🔍
-2% - +0%
-1.46ms - +0.22ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local6.24ms - 6.87ms-unsure 🔍
-7% - +7%
-0.43ms - +0.46ms
preact-main6.23ms - 6.85msunsure 🔍
-7% - +6%
-0.46ms - +0.43ms
-
many-updates
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.09ms - 16.85ms-unsure 🔍
-2% - +4%
-0.26ms - +0.72ms
preact-main15.93ms - 16.56msunsure 🔍
-4% - +2%
-0.72ms - +0.26ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.72ms - 3.73ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main3.72ms - 3.73msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local61.11ms - 62.06ms-unsure 🔍
-1% - +1%
-0.73ms - +0.65ms
preact-main61.12ms - 62.13msunsure 🔍
-1% - +1%
-0.65ms - +0.73ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.99ms - 2.99ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main2.99ms - 2.99msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.93ms - 26.83ms-unsure 🔍
-1% - +3%
-0.31ms - +0.87ms
preact-main25.72ms - 26.48msunsure 🔍
-3% - +1%
-0.87ms - +0.31ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local32.91ms - 33.92ms-unsure 🔍
-2% - +2%
-0.79ms - +0.66ms
preact-main32.96ms - 34.00msunsure 🔍
-2% - +2%
-0.66ms - +0.79ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local33.80ms - 34.61ms-unsure 🔍
-2% - +2%
-0.57ms - +0.57ms
preact-main33.81ms - 34.61msunsure 🔍
-2% - +2%
-0.57ms - +0.57ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local27.48ms - 27.84ms-unsure 🔍
-1% - +1%
-0.37ms - +0.15ms
preact-main27.58ms - 27.96msunsure 🔍
-1% - +1%
-0.15ms - +0.37ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local25.61ms - 27.13ms-unsure 🔍
-3% - +5%
-0.72ms - +1.28ms
preact-main25.44ms - 26.74msunsure 🔍
-5% - +3%
-1.28ms - +0.72ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local22.39ms - 22.78ms-unsure 🔍
-1% - +2%
-0.21ms - +0.36ms
preact-main22.31ms - 22.72msunsure 🔍
-2% - +1%
-0.36ms - +0.21ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 230
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.76ms - 1.88ms-unsure 🔍
-6% - +2%
-0.12ms - +0.03ms
preact-main1.82ms - 1.91msunsure 🔍
-2% - +7%
-0.03ms - +0.12ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local0.98ms - 1.01ms-unsure 🔍
-2% - +2%
-0.02ms - +0.02ms
preact-main0.98ms - 1.01msunsure 🔍
-2% - +2%
-0.02ms - +0.02ms
-
todo
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.94ms - 32.34ms-unsure 🔍
-1% - +1%
-0.26ms - +0.28ms
preact-main31.94ms - 32.32msunsure 🔍
-1% - +1%
-0.28ms - +0.26ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.25ms - 1.25ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main1.24ms - 1.25msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
update10th1k
  • Browser: chrome-headless
  • Sample size: 60
  • Built by: CI #5398
  • Commit: 93ff06a

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.18ms - 31.51ms-unsure 🔍
-2% - +4%
-0.73ms - +1.29ms
preact-main29.80ms - 31.32msunsure 🔍
-4% - +2%
-1.29ms - +0.73ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.95ms - 2.96ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main2.94ms - 2.95msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-

tachometer-reporter-action v2 for CI

@coveralls
Copy link

Coverage Status

coverage: 99.537%. remained the same
when pulling 93ff06a on ali-garajian:main
into 4885f1d on preactjs:main.

@rschristian
Copy link
Member

.startsWith was newer than our targets allowed for v10, v11 could be viable if it's faster cross-browser. Might very well be

@ali-garajian
Copy link
Contributor Author

ali-garajian commented Feb 22, 2026

I noticed it adds 14B to the bundle size

@rschristian is it a fair tradeoff?

@rschristian
Copy link
Member

Firefox (Linux) Chromium (Linux)
Firefox (Linux) Chromium (Linux)

Without the benches pointing towards any perf increase in this repo (microbenchmarks like the one above can be useful, but we need to measure holistic perf here), I'd say that unless you can get the byte impact down (by using .startsWith elsewhere maybe?), this probably isn't worthwhile.

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