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

Add functionality to run autocannon forever. #94

Merged
merged 12 commits into from
Nov 11, 2016

Conversation

GlenTiki
Copy link
Collaborator

@GlenTiki GlenTiki commented Nov 8, 2016

  • tests & documentation

fixes #92

No perf damage over multiple runs.

@GlenTiki
Copy link
Collaborator Author

GlenTiki commented Nov 8, 2016

Weird, I actually fixed the test issue locally on my machine before pushing, but it is appearing again on CI. investigating

@GlenTiki
Copy link
Collaborator Author

GlenTiki commented Nov 8, 2016

sigh. Nothing happened here. Move along.

@eljefedelrodeodeljefe
Copy link

Awesome

t.end()
}, 1000)
}
})
Copy link
Owner

Choose a reason for hiding this comment

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

A callback should be called only once, we should probably move away from the callback, and use an EventEmitter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, this is a weird case, and I only planned on using the event emitter approach. But I realised that this is possible when writing the test so I used it. In the case forever is true, should we throw if a callback is passed in?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, I think so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This adds much more complexity when handling options. Have it working, will push so you can review

instance.on('response', () => { amountProgressBar.tick() })
instance.on('reqError', () => { amountProgressBar.tick() })
instance.on('done', () => { amountProgressBar.tick(iOpts.amount - 1) })
process.once('SIGINT', () => { amountProgressBar.tick(iOpts.amount - 1) })
Copy link
Owner

Choose a reason for hiding this comment

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

can we factor this out into a function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but it should only be run once, so I left it in the scope of this function to make it clear to readers that this is should only be run once, when the track function is ran.

Copy link
Owner

Choose a reason for hiding this comment

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

I mean, the code above for both amountProgressBar and durationProgressBar looks very similar. we should probably factor it out in its own function, ideally calling the same function with different parameters, or something similar.

(this is a nit of style, nothing more)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could curry the callbacks for the events with the relevant progress bar var & amount to tick by (undefined in the case of raw .tick()). Thoughts?

Copy link
Owner

Choose a reason for hiding this comment

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

That would a nice improvement!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, so I did the currying thing, and felt super happy with it, and then realised why I had them written like that when it crashed. I use the scope of the progressBar variables to instantiate new ones when restarting the benchmark, but use the same variable reference. By currying, I lose access to the scope-referencing-closure-benefit. I would like to leave this as is, because to get something "cleaner" working would end up adding add much more code, and not necessarily add any benefit. Is that okay with you?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, but put in a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

comment in.

Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

This seems ready to me. Anything more to add?

@GlenTiki
Copy link
Collaborator Author

If you're happy with this @mcollina, feel free to merge. I don't think I can add anymore to it 👍

@mcollina mcollina merged commit 20ceb96 into mcollina:master Nov 11, 2016
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.

feature_request: make autocannon run indefinitely whilst emitting reports periodically
3 participants