-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
enhancementNew feature or requestNew feature or request
Description
@kirbysayshi suggested:
As I'm looking through the other cases for setup, the common pattern seems to be that the setup is run once, completely outside of benchmark.js (this makes sense since it doesn't support async setup). But there could be a deeper concern here too: only running the setup function once could result in inconsistent start state for the clocked function:
add('array truncation', async () => { const arr = (new Array(1000)).fill(true); return async () => { // on the first run, this will actually truncate the array. // on subsequent runs, the length would already be zero since the setup state is shared. arr.length = 0; } })
I open this issue to reconsider this behavior for impure functions that can mutate setup.
kirbysayshi, v1rtl and ncovercashminhui-foxtel
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request