-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
✅ Deploy Preview for vapor-repl ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for vapor-template-explorer ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Size ReportBundles
Usages
|
rows.value.push(...buildData(1000)) | ||
triggerRef(rows) |
There was a problem hiding this comment.
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.
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() | ||
}) |
There was a problem hiding this comment.
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)
commit: @vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-shared
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
@vue/vapor
|
e5217c3
to
ed45f05
Compare
benchmark/client/App.vue
Outdated
// 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) |
There was a problem hiding this comment.
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)
.
91e12cc
to
f25b249
Compare
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