You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()=>{constarr=(newArray(1000)).fill(true);returnasync()=>{// 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.
The text was updated successfully, but these errors were encountered:
I agree; I'd really like more fine-grained control over the lifecycle. Maybe this could be implemented like:
benny.add('reconcile only',(ctx)=>{constdata=// something to create a data setctx.start();reconcile(data);ctx.end();});
With something like this, we could control specifically which part of the function is counted in the timing. This would be particularly useful for me, since I'm looking for something that can separate out the steps of a two-stage upload process and tell me what amount of time is spent on each, but currently I have no way to do that. Perhaps something like:
With this, the final result could be the total time of the entire function, but there'd be an additional property containing statistics for each step individually.
@kirbysayshi suggested:
I open this issue to reconsider this behavior for impure functions that can mutate setup.
The text was updated successfully, but these errors were encountered: