-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
|
||
test('reset histogram', (t) => { | ||
const instance = new Histogram(1, 100) | ||
t.equal(instance.min(), 9223372036854776000, 'min is setup') |
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.
@mcollina I discovered this tidbit when writing my tests, I have recreated it several times. should this be acceptable? its an empty instance.
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.
Not really.
However it is a bug in the C library. We might open a separate bug there.
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.
👍
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.
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.
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.
& 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" |
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.
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); |
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.
@mcollina Wasn't sure if I should or should not return here.
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.
IMHO we should return the histogram, or undefined.
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.
I'll return the histogram.
|
||
test('reset histogram', (t) => { | ||
const instance = new Histogram(1, 100) | ||
t.equal(instance.min(), 9223372036854776000, 'min is setup') |
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.
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); |
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.
IMHO we should return the histogram, or undefined.
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.
LGTM
This is so I can work on something for mcollina/autocannon#92