Skip to content

Performance: compat shallowDiffers #4780

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

romgrk
Copy link

@romgrk romgrk commented May 29, 2025

This util is used to compare props. Props are more likely (I'm guessing) to have the same shape from one render to the next. Therefore, it's better to check first if the values differ than if the keys differ.

This benchmark compares 20-keys objects with the same shape for the same-values and different-values cases.

image

Benchmark: https://github.com/romgrk/js-benchmark/blob/master/benchmarks/object-shallow-compare.js

Copy link

github-actions bot commented May 29, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +0% (-3.45ms - +4.64ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.22ms - +0.03ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.25ms - +1.03ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +2% (-0.40ms - +0.33ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.80ms - +0.91ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +5% (-0.06ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -2% - +1% (-0.78ms - +0.22ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -4% - +2% (-1.13ms - +0.64ms)
    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 🔍 -5% - +4% (-0.36ms - +0.31ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -2% - +4% (-0.02ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +2% (-0.01ms - +0.02ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local975.08ms - 980.94ms-unsure 🔍
-0% - +0%
-3.45ms - +4.64ms
preact-main974.63ms - 980.20msunsure 🔍
-0% - +0%
-4.64ms - +3.45ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.18ms - 19.18ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main19.18ms - 19.18msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.51ms - 16.55ms-unsure 🔍
-1% - +0%
-0.22ms - +0.03ms
preact-main16.50ms - 16.75msunsure 🔍
-0% - +1%
-0.03ms - +0.22ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.54ms - 1.54ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.54ms - 1.54msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local71.12ms - 72.76ms-unsure 🔍
-2% - +1%
-1.25ms - +1.03ms
preact-main71.26ms - 72.84msunsure 🔍
-1% - +2%
-1.03ms - +1.25ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local7.50ms - 8.00ms-unsure 🔍
-5% - +4%
-0.36ms - +0.31ms
preact-main7.55ms - 8.00msunsure 🔍
-4% - +5%
-0.31ms - +0.36ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.61ms - 17.11ms-unsure 🔍
-2% - +2%
-0.40ms - +0.33ms
preact-main16.63ms - 17.16msunsure 🔍
-2% - +2%
-0.33ms - +0.40ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.77ms - 3.78ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.77ms - 3.78msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4720
  • Commit: 4a9b4a4

duration

VersionAvg timevs preact-localvs preact-main
preact-local62.52ms - 63.77ms-unsure 🔍
-1% - +1%
-0.80ms - +0.91ms
preact-main62.51ms - 63.68msunsure 🔍
-1% - +1%
-0.91ms - +0.80ms
-

usedJSHeapSize

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

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.96ms - 26.70ms-unsure 🔍
-2% - +1%
-0.60ms - +0.38ms
preact-main26.11ms - 26.76msunsure 🔍
-1% - +2%
-0.38ms - +0.60ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.40ms - 34.78ms-unsure 🔍
-3% - +3%
-1.05ms - +1.01ms
preact-main33.35ms - 34.87msunsure 🔍
-3% - +3%
-1.01ms - +1.05ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.27ms - 30.20ms-unsure 🔍
-1% - +4%
-0.28ms - +1.06ms
preact-main28.86ms - 29.83msunsure 🔍
-4% - +1%
-1.06ms - +0.28ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.92ms - 27.86ms-unsure 🔍
-3% - +2%
-0.78ms - +0.60ms
preact-main26.97ms - 27.99msunsure 🔍
-2% - +3%
-0.60ms - +0.78ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.25ms - 24.39ms-unsure 🔍
-4% - +3%
-0.87ms - +0.67ms
preact-main23.40ms - 24.43msunsure 🔍
-3% - +4%
-0.67ms - +0.87ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.96ms - 21.59ms-unsure 🔍
-4% - +1%
-0.87ms - +0.20ms
preact-main21.17ms - 22.04msunsure 🔍
-1% - +4%
-0.20ms - +0.87ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 140
  • Built by: CI #4720
  • Commit: 4a9b4a4

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.05ms - 2.16ms-unsure 🔍
-3% - +5%
-0.06ms - +0.10ms
preact-main2.03ms - 2.14msunsure 🔍
-5% - +3%
-0.10ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.16ms - 1.21ms-unsure 🔍
-2% - +4%
-0.02ms - +0.05ms
preact-main1.15ms - 1.19msunsure 🔍
-4% - +2%
-0.05ms - +0.02ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.34ms - 33.60ms-unsure 🔍
-2% - +1%
-0.78ms - +0.22ms
preact-main33.27ms - 34.23msunsure 🔍
-1% - +2%
-0.22ms - +0.78ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.24ms - 1.26ms-unsure 🔍
-1% - +2%
-0.01ms - +0.02ms
preact-main1.24ms - 1.26msunsure 🔍
-2% - +1%
-0.02ms - +0.01ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.20ms - 31.44ms-unsure 🔍
-4% - +2%
-1.13ms - +0.64ms
preact-main30.43ms - 31.70msunsure 🔍
-2% - +4%
-0.64ms - +1.13ms
-

usedJSHeapSize

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

tachometer-reporter-action v2 for CI

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