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: improve benchmark test code #268

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Conversation

LittleSound
Copy link
Member

@LittleSound LittleSound commented Aug 17, 2024

To better for the performance of Vue Vapor, improve the benchmark test code based on the architectural features of Vapor.

I have synchronized these changes to JS Framework Benchmark repo.
In krausest/js-framework-benchmark#1729

Copy link

netlify bot commented Aug 17, 2024

Deploy Preview for vapor-repl ready!

Name Link
🔨 Latest commit f25b249
🔍 Latest deploy log https://app.netlify.com/sites/vapor-repl/deploys/66c3113d19efcb0008fcef37
😎 Deploy Preview https://deploy-preview-268--vapor-repl.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 17, 2024

Deploy Preview for vapor-template-explorer ready!

Name Link
🔨 Latest commit f25b249
🔍 Latest deploy log https://app.netlify.com/sites/vapor-template-explorer/deploys/66c3113decd44400081ff4a1
😎 Deploy Preview https://deploy-preview-268--vapor-template-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 80.6 kB 28.4 kB 25 kB
compiler-vapor.global.prod.js 56.9 kB 19.4 kB 17.6 kB
runtime-dom.global.prod.js 99.3 kB 37.6 kB 33.8 kB
runtime-vapor.global.prod.js 48.6 kB 18.3 kB 16.7 kB
vue-vapor.global.prod.js 103 kB 36.2 kB 32.5 kB
vue.global.prod.js 157 kB 57.4 kB 51 kB

Usages

Name Size Gzip Brotli
createApp 55.2 kB 21.3 kB 19.4 kB
createSSRApp 59.1 kB 22.9 kB 20.9 kB
defineCustomElement 59.8 kB 22.8 kB 20.8 kB
vapor 49.2 kB 18.5 kB 16.9 kB
overall 68.8 kB 26.3 kB 23.9 kB

Comment on lines +25 to +26
rows.value.push(...buildData(1000))
triggerRef(rows)
Copy link
Member Author

Choose a reason for hiding this comment

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

I tested different options for adding items to an existing arrow on jsbench.me. this is the fastest.

Comment on lines 46 to 51
const update = wrap('update', () => {
const _rows = rows.value
for (let i = 0; i < _rows.length; i += 10) {
_rows[i].label += ' !!!'
for (let i = 0, len = _rows.length; i < len; i += 10) {
_rows[i].label.value += ' !!!'
}
setRows()
})
Copy link
Member Author

Choose a reason for hiding this comment

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

the time complexity of this update has improved from O(n) to O(n/10)

Copy link

pkg-pr-new bot commented Aug 17, 2024

commit: f25b249

@vue/compiler-core

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-core@268

@vue/compiler-dom

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-dom@268

@vue/compiler-sfc

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-sfc@268

@vue/compiler-ssr

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-ssr@268

@vue/compiler-vapor

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-vapor@268

@vue/reactivity

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/reactivity@268

@vue/runtime-core

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/runtime-core@268

@vue/runtime-dom

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/runtime-dom@268

@vue/runtime-shared

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/runtime-shared@268

@vue/runtime-vapor

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/runtime-vapor@268

@vue/server-renderer

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/server-renderer@268

@vue/shared

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/shared@268

vue

pnpm add https://pkg.pr.new/vuejs/core-vapor/vue@268

@vue/compat

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/compat@268

@vue/vapor

pnpm add https://pkg.pr.new/vuejs/core-vapor/@vue/vapor@268

Open in Stackblitzplayground

@LittleSound LittleSound force-pushed the perf/improve-benchmark-test-code branch from e5217c3 to ed45f05 Compare August 17, 2024 16:38
Comment on lines 82 to 92
// Reduce the complexity of `selected` from O(n) to O(1).
function createSelector(source: WatchSource) {
const list: Record<keyof any, ShallowRef<boolean>> = {}
watch(source, (val, old) => {
if (old != undefined) list[old]!.value = false
if (val != undefined) list[val]!.value = true
})
return (id: keyof any) => (list[id] ??= shallowRef(false)).value
}

const isSelected = createSelector(selected)
Copy link
Member Author

Choose a reason for hiding this comment

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

Reduce the time complexity of this selected from O(n) to O(1).

@LittleSound LittleSound force-pushed the perf/improve-benchmark-test-code branch from 91e12cc to f25b249 Compare August 19, 2024 09:32
@sxzz sxzz merged commit 6791c88 into main Sep 17, 2024
11 checks passed
@sxzz sxzz deleted the perf/improve-benchmark-test-code branch September 17, 2024 15:19
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