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 method to reset the histogram #10

Merged
merged 3 commits into from
Nov 6, 2016
Merged

Conversation

GlenTiki
Copy link
Collaborator

@GlenTiki GlenTiki commented Nov 3, 2016

This is so I can work on something for mcollina/autocannon#92


test('reset histogram', (t) => {
const instance = new Histogram(1, 100)
t.equal(instance.min(), 9223372036854776000, 'min is setup')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mcollina I discovered this tidbit when writing my tests, I have recreated it several times. should this be acceptable? its an empty instance.

Copy link
Owner

Choose a reason for hiding this comment

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

Not really.
However it is a bug in the C library. We might open a separate bug there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn 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've done some research on this, I don't believe it the issue we thought it. The min value should be initialised to positive infinity, and max value to negative infinity. It means the check for greater than or less than values are not complex logic trees, and you just use the single variables from initialisation in implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

& relevant issue: HdrHistogram/HdrHistogram#54

@@ -7,7 +7,7 @@
"scripts": {
"prepublish": "npm ls",
"install": "node-pre-gyp install --fallback-to-build",
"test": "node-pre-gyp install --fallback-to-build && standard && tap test.js"
"test": "node-pre-gyp install --build-from-source && standard && tap test.js"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed this command to ensure when running tests it always rebuilds. Previously it used any existing build, which wasn't optimal in dev.

NAN_METHOD(HdrHistogramWrap::Reset) {
HdrHistogramWrap* obj = Nan::ObjectWrap::Unwrap<HdrHistogramWrap>(info.This());
hdr_reset(obj->histogram);
info.GetReturnValue().Set(true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mcollina Wasn't sure if I should or should not return here.

Copy link
Owner

Choose a reason for hiding this comment

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

IMHO we should return the histogram, or undefined.

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'll return the histogram.


test('reset histogram', (t) => {
const instance = new Histogram(1, 100)
t.equal(instance.min(), 9223372036854776000, 'min is setup')
Copy link
Owner

Choose a reason for hiding this comment

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

Not really.
However it is a bug in the C library. We might open a separate bug there.

NAN_METHOD(HdrHistogramWrap::Reset) {
HdrHistogramWrap* obj = Nan::ObjectWrap::Unwrap<HdrHistogramWrap>(info.This());
hdr_reset(obj->histogram);
info.GetReturnValue().Set(true);
Copy link
Owner

Choose a reason for hiding this comment

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

IMHO we should return the histogram, or undefined.

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.

LGTM

@GlenTiki GlenTiki merged commit d795175 into mcollina:master Nov 6, 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.

2 participants