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

Tree shake class components #3591

Merged
merged 4 commits into from Jun 30, 2022
Merged

Tree shake class components #3591

merged 4 commits into from Jun 30, 2022

Conversation

JoviDeCroock
Copy link
Member

This PR introduces tree-shaking for class components, we have a test repo where we have tested this with vite and the results are 500bytes less!!!

## With class-components
$ vite build
vite v2.9.13 building for production...
✓ 5 modules transformed.
dist/index.html                 0.38 KiB
dist/assets/index.6f0ba079.js   11.62 KiB / gzip: 4.73 KiB
✨  Done in 0.81s.

## Without class-components
❯ yarn build
yarn run v1.22.17
$ vite build
vite v2.9.13 building for production...
✓ 5 modules transformed.
dist/index.html                 0.38 KiB
dist/assets/index.917e7781.js   10.04 KiB / gzip: 4.23 KiB
✨  Done in 0.70s.

@github-actions
Copy link

github-actions bot commented Jun 27, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -1% - +2% (-2.18ms - +3.69ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -2% - +5% (-1.26ms - +2.71ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -0% - +0% (-5.68ms - +5.48ms)
    preact-local vs preact-master
  • filter_list: slower ❌ 0% - 7% (4.92ms - 72.03ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -2% - +15% (-2.09ms - +19.28ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -6% - +3% (-45.53ms - +27.74ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -6% - +7% (-21.18ms - +24.91ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -0% - +3% (-0.16ms - +1.25ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.00ms - +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.02ms - +0.01ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -0% - +1% (-0.00ms - +0.02ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 +0% - +0% (+0.00ms - +0.01ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -2% - +1% (-0.02ms - +0.02ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master176.90ms - 181.10ms-unsure 🔍
-2% - +1%
-3.69ms - +2.18ms
preact-local177.71ms - 181.81msunsure 🔍
-1% - +2%
-2.18ms - +3.69ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.16ms - 4.17ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-local4.17ms - 4.17msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-local
preact-master62.82ms - 64.89ms-unsure 🔍
-3% - +2%
-2.05ms - +1.11ms
preact-local63.13ms - 65.52msunsure 🔍
-2% - +3%
-1.11ms - +2.05ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-local
preact-master76.64ms - 79.52ms-unsure 🔍
-1% - +4%
-0.99ms - +2.96ms
preact-local75.74ms - 78.44msunsure 🔍
-4% - +1%
-2.96ms - +0.99ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-local
preact-master73.17ms - 75.68ms-unsure 🔍
-3% - +2%
-2.40ms - +1.32ms
preact-local73.59ms - 76.33msunsure 🔍
-2% - +3%
-1.32ms - +2.40ms
-

run-final

VersionAvg timevs preact-mastervs preact-local
preact-master176.94ms - 181.14ms-unsure 🔍
-2% - +1%
-3.68ms - +2.19ms
preact-local177.73ms - 181.83msunsure 🔍
-1% - +2%
-2.19ms - +3.68ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-local
preact-master58.55ms - 61.55ms-unsure 🔍
-4% - +2%
-2.71ms - +1.26ms
preact-local59.47ms - 62.07msunsure 🔍
-2% - +5%
-1.26ms - +2.71ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.18ms - 4.19ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-local4.19ms - 4.20msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master1598.45ms - 1605.32ms-unsure 🔍
-0% - +0%
-5.48ms - +5.68ms
preact-local1597.38ms - 1606.19msunsure 🔍
-0% - +0%
-5.68ms - +5.48ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master28.41ms - 28.43ms-unsure 🔍
-0% - +0%
-0.01ms - +0.02ms
preact-local28.40ms - 28.43msunsure 🔍
-0% - +0%
-0.02ms - +0.01ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-local
preact-master989.87ms - 1043.62ms-faster ✔
1% - 7%
4.92ms - 72.03ms
preact-local1035.12ms - 1075.32msslower ❌
0% - 7%
4.92ms - 72.03ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master2.10ms - 2.11ms-unsure 🔍
-1% - +0%
-0.02ms - +0.00ms
preact-local2.10ms - 2.11msunsure 🔍
-0% - +1%
-0.00ms - +0.02ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master122.99ms - 138.79ms-unsure 🔍
-14% - +1%
-19.28ms - +2.09ms
preact-local132.30ms - 146.67msunsure 🔍
-2% - +15%
-2.09ms - +19.28ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master6.92ms - 6.92ms-unsure 🔍
-0% - -0%
-0.01ms - -0.00ms
preact-local6.92ms - 6.92msunsure 🔍
+0% - +0%
+0.00ms - +0.01ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-local
preact-master792.20ms - 845.43ms-unsure 🔍
-3% - +6%
-27.74ms - +45.53ms
preact-local784.75ms - 835.10msunsure 🔍
-6% - +3%
-45.53ms - +27.74ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master5.72ms - 5.73ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-local5.72ms - 5.72msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-local
preact-master331.48ms - 364.20ms-unsure 🔍
-7% - +6%
-24.91ms - +21.18ms
preact-local333.47ms - 365.94msunsure 🔍
-6% - +7%
-21.18ms - +24.91ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.31ms - 1.31ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-local1.31ms - 1.32msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-local
preact-master42.59ms - 42.90ms-unsure 🔍
-3% - +0%
-1.25ms - +0.16ms
preact-local42.60ms - 43.98msunsure 🔍
-0% - +3%
-0.16ms - +1.25ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.33ms - 1.36ms-unsure 🔍
-1% - +2%
-0.02ms - +0.02ms
preact-local1.33ms - 1.35msunsure 🔍
-2% - +1%
-0.02ms - +0.02ms
-

tachometer-reporter-action v2 for Benchmarks

@github-actions
Copy link

github-actions bot commented Jun 27, 2022

Size Change: +48 B (0%)

Total Size: 38 kB

Filename Size Change
dist/preact.js 4.71 kB +14 B (0%)
dist/preact.min.js 4.77 kB +19 B (0%)
dist/preact.umd.js 4.79 kB +15 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.6 kB 0 B
compat/dist/compat.umd.js 3.68 kB 0 B
debug/dist/debug.js 3.08 kB 0 B
debug/dist/debug.umd.js 3.17 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.umd.js 316 B 0 B
hooks/dist/hooks.js 1.29 kB 0 B
hooks/dist/hooks.umd.js 1.38 kB 0 B
jsx-runtime/dist/jsxRuntime.js 342 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 425 B 0 B
server/dist/server.js 2.6 kB 0 B
server/dist/server.umd.js 2.69 kB 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.umd.js 522 B 0 B

compressed-size-action

@coveralls
Copy link

coveralls commented Jun 27, 2022

Coverage Status

Coverage increased (+0.002%) to 99.442% when pulling 073a0aa on tree-shake-class-components into d269b75 on main.

@JoviDeCroock JoviDeCroock merged commit 7115c92 into main Jun 30, 2022
@JoviDeCroock JoviDeCroock deleted the tree-shake-class-components branch June 30, 2022 10:36
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.

None yet

3 participants