-
Notifications
You must be signed in to change notification settings - Fork 773
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
vm: skip _runStepHook
method if no step event listener
#1676
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Looks good, tested this with the following code:
import VM from './src'
let vm = new VM()
vm.listenerCount('step') // 0
vm.on('step', () => { console.log('Called step') })
vm.listenerCount('step') // 1
This should also be implicitly covered by tests in tests/api/events.spec.ts
.
Read something about this in the chat but couldn't find any more, so was there actually some impact on performance by this change?
Argh, this can actually be directly reverted again. The Could you guys please have a minimal look into the code base itself before you comment out some stuff? 😐 This is a bit annoying and a bit too sloppy to overlook. |
Argh, sorry this is my fault @holgerd77, I pitched this to @acolytec3 as "low hanging fruit" optimization and did skim over the code to convince myself there were no side effects if we disabled it with no listeners. Clearly I was not careful and did not take enough time to notice there were in fact side effects. My apologies! 😞 |
Thanks, no worries, nothing which can't be reverted. Generally a good idea. Respectively, on looking at the code again: this just seems to need an additional |
Ugh, sorry, that wasn't obvious to me though I wondered about the flag. I'll add another PR tonight to address. |
Adds a check in the
interpreter
to skip the_runStepHook
function if there are nostep
event listeners since this method's sole purpose is to create and emit thestep
event. Thestep
is only used in tests in our code base so this should produce some (likely minor) overall improvement in VM performance since this function is run on each step in VM execution.