Closed BridgeAR closed 6 years ago
hey @BridgeAR !! thanks for this and the doc updates, very much appreciated
for this module, for any changes to the code, no matter how minor, it's important to see benchmark results (just in case)
could you post before/after benchmark results for Node 6 and 8?
I doubt there'll be any performance impact (positive or negative) but once we have that recorded here, I'll go ahead and merge
New:
fastSafeStringifyBench*100000: 119.069ms
fastSafeStringifyCircBench*100000: 171.838ms
fastSafeStringifyDeepBench*100000: 2241.229ms
fastSafeStringifyDeepCircBench*100000: 2469.610ms
fastSafeStringifyDeepTryFirstBench*100000: 1779.870ms
fastSafeStringifyBench*100000: 112.919ms
fastSafeStringifyCircBench*100000: 163.486ms
fastSafeStringifyDeepBench*100000: 2218.838ms
fastSafeStringifyDeepCircBench*100000: 2497.698ms
fastSafeStringifyDeepTryFirstBench*100000: 1765.853ms
fastSafeStringifyBench*100000: 123.904ms
fastSafeStringifyCircBench*100000: 168.784ms
fastSafeStringifyDeepBench*100000: 2283.988ms
fastSafeStringifyDeepCircBench*100000: 2291.381ms
fastSafeStringifyDeepTryFirstBench*100000: 1781.112ms
fastSafeStringifyBench*100000: 113.951ms
fastSafeStringifyCircBench*100000: 169.060ms
fastSafeStringifyDeepBench*100000: 2189.786ms
fastSafeStringifyDeepCircBench*100000: 2312.131ms
fastSafeStringifyDeepTryFirstBench*100000: 1804.630ms
Old
fastSafeStringifyBench*100000: 123.402ms
fastSafeStringifyCircBench*100000: 182.026ms
fastSafeStringifyDeepBench*100000: 2379.344ms
fastSafeStringifyDeepCircBench*100000: 2639.922ms
fastSafeStringifyDeepTryFirstBench*100000: 1783.709ms
fastSafeStringifyBench*100000: 117.693ms
fastSafeStringifyCircBench*100000: 171.801ms
fastSafeStringifyDeepBench*100000: 2378.560ms
fastSafeStringifyDeepCircBench*100000: 2466.636ms
fastSafeStringifyDeepTryFirstBench*100000: 1786.094ms
fastSafeStringifyBench*100000: 125.419ms
fastSafeStringifyCircBench*100000: 186.527ms
fastSafeStringifyDeepBench*100000: 2327.771ms
fastSafeStringifyDeepCircBench*100000: 2472.491ms
fastSafeStringifyDeepTryFirstBench*100000: 1702.568ms
fastSafeStringifyBench*100000: 118.699ms
fastSafeStringifyCircBench*100000: 177.595ms
fastSafeStringifyDeepBench*100000: 2365.255ms
fastSafeStringifyDeepCircBench*100000: 2440.229ms
fastSafeStringifyDeepTryFirstBench*100000: 1722.473ms
Due to the comment I had another look at the code and did a bit of a performance optimization while also reducing the complexity of the code further.
Here the comparison against other code (I can add another commit to update that as well, but I guess that is not that important):
inspectBench*10000: 25.439ms
jsonStringifySafeBench*10000: 25.413ms
fastSafeStringifyBench*10000: 13.111ms
inspectCircBench*10000: 46.579ms
jsonStringifyCircSafeBench*10000: 41.873ms
fastSafeStringifyCircBench*10000: 25.063ms
inspectDeepBench*10000: 383.180ms
jsonStringifySafeDeepBench*10000: 841.261ms
fastSafeStringifyDeepBench*10000: 281.529ms
inspectDeepCircBench*10000: 421.872ms
jsonStringifySafeDeepCircBench*10000: 849.294ms
fastSafeStringifyDeepCircBench*10000: 302.111ms
magnificent – thanks @BridgeAR
This minimizes the code for readability. Even though I added a theoretical optimization for primitives, I can not see any difference in the benchmarks (also not with higher n).