preact icon indicating copy to clipboard operation
preact copied to clipboard

Optimization: use replaceChild where possible

Open developit opened this issue 4 years ago • 2 comments
trafficstars

This uses ParentNode.replaceChild() in the case where insertion is happening at the last index in a list, since it is not possible for an old DOM node to be left in-position after the inserted node. It does not avoid the .removeChild() call for the old DOM node, since that is a cheap noop for already-removed nodes.

developit avatar Nov 17 '21 18:11 developit

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -3% - +2% (-3.83ms - +2.91ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -2% - +5% (-0.62ms - +1.94ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -0% - +2% (-6.98ms - +27.15ms)
    preact-local vs preact-master
  • filter_list: slower ❌ 17% - 24% (4.90ms - 6.60ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -6% - +7% (-12.26ms - +16.13ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -4% - +3% (-1.28ms - +0.98ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -5% - +4% (-0.18ms - +0.15ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -1% - +1% (-0.04ms - +0.06ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master

Results

02_replace1k
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 80
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master147.09ms - 151.85ms-unsure 🔍
-2% - +3%
-2.91ms - +3.83ms
preact-local146.62ms - 151.39msunsure 🔍
-3% - +2%
-3.83ms - +2.91ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.48ms - 3.49ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-local3.48ms - 3.49msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-local
preact-master54.85ms - 56.72ms-unsure 🔍
-2% - +2%
-1.10ms - +1.27ms
preact-local54.97ms - 56.42msunsure 🔍
-2% - +2%
-1.27ms - +1.10ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-local
preact-master83.64ms - 86.30ms-unsure 🔍
-3% - +2%
-2.27ms - +1.79ms
preact-local83.68ms - 86.74msunsure 🔍
-2% - +3%
-1.79ms - +2.27ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-local
preact-master74.00ms - 80.57ms-unsure 🔍
-6% - +6%
-4.74ms - +4.60ms
preact-local74.03ms - 80.67msunsure 🔍
-6% - +6%
-4.60ms - +4.74ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-local
preact-master57.60ms - 63.75ms-unsure 🔍
-6% - +10%
-3.51ms - +5.71ms
preact-local56.14ms - 63.01msunsure 🔍
-9% - +6%
-5.71ms - +3.51ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-local
preact-master83.51ms - 86.86ms-unsure 🔍
-4% - +3%
-3.38ms - +2.18ms
preact-local83.56ms - 88.00msunsure 🔍
-3% - +4%
-2.18ms - +3.38ms
-

run-final

VersionAvg timevs preact-mastervs preact-local
preact-master57.64ms - 60.00ms-unsure 🔍
-1% - +5%
-0.50ms - +3.01ms
preact-local56.26ms - 58.87msunsure 🔍
-5% - +1%
-3.01ms - +0.50ms
-
03_update10th1k_x16
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 120
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master36.19ms - 37.86ms-unsure 🔍
-5% - +2%
-1.94ms - +0.62ms
preact-local36.72ms - 38.66msunsure 🔍
-2% - +5%
-0.62ms - +1.94ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.54ms - 3.55ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-local3.54ms - 3.56msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-
07_create10k
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 50
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master1764.57ms - 1788.47ms-unsure 🔍
-2% - +0%
-27.15ms - +6.98ms
preact-local1774.42ms - 1798.78msunsure 🔍
-0% - +2%
-6.98ms - +27.15ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master25.32ms - 25.32ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-local25.32ms - 25.32msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
filter_list
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 50
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master27.70ms - 29.14ms-faster ✔
14% - 19%
4.90ms - 6.60ms
preact-local33.72ms - 34.62msslower ❌
17% - 24%
4.90ms - 6.60ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.54ms - 1.54ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-local1.54ms - 1.54msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
hydrate1k
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 70
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master213.18ms - 233.36ms-unsure 🔍
-7% - +5%
-16.13ms - +12.26ms
preact-local215.21ms - 235.20msunsure 🔍
-6% - +7%
-12.26ms - +16.13ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master6.15ms - 6.22ms-unsure 🔍
-1% - +1%
-0.06ms - +0.04ms
preact-local6.16ms - 6.23msunsure 🔍
-1% - +1%
-0.04ms - +0.06ms
-
many_updates
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 50
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master27.94ms - 29.57ms-unsure 🔍
-3% - +4%
-0.98ms - +1.28ms
preact-local27.82ms - 29.38msunsure 🔍
-4% - +3%
-1.28ms - +0.98ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.61ms - 4.61ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-local4.61ms - 4.61msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
text_update
  • Browser: chrome-headless 95.0.4638.69
  • Sample size: 110
  • Built by: Benchmarks #526
  • Commit: aa33eab

duration

VersionAvg timevs preact-mastervs preact-local
preact-master3.66ms - 3.95ms-unsure 🔍
-4% - +5%
-0.15ms - +0.18ms
preact-local3.70ms - 3.87msunsure 🔍
-5% - +4%
-0.18ms - +0.15ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master0.78ms - 0.78ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-local0.78ms - 0.78msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-

tachometer-reporter-action v2 for Benchmarks

github-actions[bot] avatar Nov 17 '21 18:11 github-actions[bot]

Size Change: +101 B (0%)

Total Size: 42.1 kB

Filename Size Change
dist/preact.js 3.98 kB +25 B (0%)
dist/preact.min.js 4.01 kB +30 B (0%)
dist/preact.module.js 4 kB +25 B (0%)
dist/preact.umd.js 4.05 kB +21 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.44 kB 0 B
compat/dist/compat.module.js 3.42 kB 0 B
compat/dist/compat.umd.js 3.49 kB 0 B
debug/dist/debug.js 2.99 kB 0 B
debug/dist/debug.module.js 2.98 kB 0 B
debug/dist/debug.umd.js 3.07 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.module.js 241 B 0 B
devtools/dist/devtools.umd.js 308 B 0 B
hooks/dist/hooks.js 1.13 kB 0 B
hooks/dist/hooks.module.js 1.14 kB 0 B
hooks/dist/hooks.umd.js 1.2 kB 0 B
jsx-runtime/dist/jsxRuntime.js 317 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 327 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 395 B 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

github-actions[bot] avatar Nov 17 '21 18:11 github-actions[bot]