-
-
Notifications
You must be signed in to change notification settings - Fork 210
fix "isLong is not defined" error #73
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
fix "isLong is not defined" error #73
Conversation
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
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, can you run some benchmarks?
Why aren't there failing tests? |
@chrisguttandin can you add a unit test? You can use https://github.com/thlorenz/proxyquire to simulate |
@mcollina I basically copied the tests for long values and changed all the values to be of type integer. Thanks for pointing me to proxyquire. Let me know what you think. |
@chrisguttandin can you run the benchmarks before/after? I think we can land this as I don't expect any regressions. |
@mcollina No problem. These are the results: before: JSON.stringify array x 2,540 ops/sec ±2.77% (81 runs sampled)
fast-json-stringify array x 2,940 ops/sec ±3.54% (79 runs sampled)
fast-json-stringify-uglified array x 1,804 ops/sec ±18.49% (53 runs sampled)
JSON.stringify long string x 8,307 ops/sec ±5.03% (73 runs sampled)
fast-json-stringify long string x 8,966 ops/sec ±5.22% (78 runs sampled)
fast-json-stringify-uglified long string x 7,986 ops/sec ±3.71% (73 runs sampled)
JSON.stringify short string x 3,161,861 ops/sec ±3.63% (76 runs sampled)
fast-json-stringify short string x 6,108,401 ops/sec ±3.68% (78 runs sampled)
fast-json-stringify-uglified short string x 5,542,691 ops/sec ±10.71% (71 runs sampled)
JSON.stringify obj x 1,031,917 ops/sec ±9.72% (67 runs sampled)
fast-json-stringify obj x 2,186,183 ops/sec ±9.53% (67 runs sampled)
fast-json-stringify-uglified obj x 1,948,209 ops/sec ±7.23% (63 runs sampled) after: JSON.stringify array x 2,572 ops/sec ±2.63% (82 runs sampled)
fast-json-stringify array x 2,875 ops/sec ±4.54% (74 runs sampled)
fast-json-stringify-uglified array x 1,720 ops/sec ±17.63% (46 runs sampled)
JSON.stringify long string x 8,943 ops/sec ±9.15% (77 runs sampled)
fast-json-stringify long string x 9,774 ops/sec ±2.93% (82 runs sampled)
fast-json-stringify-uglified long string x 8,932 ops/sec ±4.24% (77 runs sampled)
JSON.stringify short string x 3,082,880 ops/sec ±4.16% (74 runs sampled)
fast-json-stringify short string x 7,078,220 ops/sec ±1.25% (86 runs sampled)
fast-json-stringify-uglified short string x 5,421,092 ops/sec ±15.64% (67 runs sampled)
JSON.stringify obj x 624,898 ops/sec ±19.23% (49 runs sampled)
fast-json-stringify obj x 2,025,581 ops/sec ±18.49% (61 runs sampled)
fast-json-stringify-uglified obj x 491,831 ops/sec ±31.24% (37 runs sampled) |
Can you run them again? The performance of |
I ran the "JSON.stringify obj" test a couple more times: before: JSON.stringify obj x 1,130,135 ops/sec ±8.23% (74 runs sampled)
JSON.stringify obj x 788,081 ops/sec ±3.88% (68 runs sampled)
JSON.stringify obj x 1,284,750 ops/sec ±1.23% (84 runs sampled)
JSON.stringify obj x 1,427,471 ops/sec ±2.01% (86 runs sampled) after: JSON.stringify obj x 1,153,374 ops/sec ±3.33% (78 runs sampled)
JSON.stringify obj x 879,321 ops/sec ±3.54% (61 runs sampled)
JSON.stringify obj x 1,267,546 ops/sec ±2.28% (81 runs sampled)
JSON.stringify obj x 1,381,669 ops/sec ±2.10% (85 runs sampled) |
This PR
master
|
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
After updating to version 1, I encountered an "isLong is not defined" error. I figured that was because I am not using the long package and it isn't installed at all in my package. Here is a little example to illustrate the problem.
Running that code will trigger the error.
I fixed the problem by extracting the checks for
isLong
from the generated code. I'm not entirely sure if that's the way it should be done, but I can imagine that it will also bring some little speed improvements as it does not insert if statements anymore which are going to fail anyway.Please let me know if you want me to make any changes.