Linux x86: node-v6.12.3
Linux x64: node-v6.12.3
Docker apline image: docker pull sthima/node-custom-build:toggle-perf-basic-prof
(Dockerfile)
From NodeJS Benchmark Guide:
Each line represents a single benchmark with parameters specified as ${variable}=${value}. Each configuration combination is executed in a separate process. This ensures that benchmark results aren't affected by the execution order due to V8 optimizations. The last number is the rate of operations measured in ops/sec (higher is better).
perf-basic-prof/toggling.js n="1" size="16" depth="16": ./node-with-object-collect: 90.666 ./node-without-object-collect: 5592.7 .. -98.38%
perf-basic-prof/toggling.js n="1" size="16" depth="32": ./node-with-object-collect: 87.364 ./node-without-object-collect: 4787.3 .. -98.18%
perf-basic-prof/toggling.js n="1" size="16" depth="64": ./node-with-object-collect: 73.447 ./node-without-object-collect: 4450.3 .. -98.35%
perf-basic-prof/toggling.js n="1" size="32" depth="16": ./node-with-object-collect: 83.141 ./node-without-object-collect: 5372.6 .. -98.45%
perf-basic-prof/toggling.js n="1" size="32" depth="32": ./node-with-object-collect: 76.937 ./node-without-object-collect: 4579.3 .. -98.32%
perf-basic-prof/toggling.js n="1" size="32" depth="64": ./node-with-object-collect: 67.977 ./node-without-object-collect: 4532.2 .. -98.50%
perf-basic-prof/toggling.js n="1" size="64" depth="16": ./node-with-object-collect: 72.069 ./node-without-object-collect: 4588.1 .. -98.43%
perf-basic-prof/toggling.js n="1" size="64" depth="32": ./node-with-object-collect: 60.514 ./node-without-object-collect: 3433.3 .. -98.24%
perf-basic-prof/toggling.js n="1" size="64" depth="64": ./node-with-object-collect: 51.736 ./node-without-object-collect: 3003.2 .. -98.28%
perf-basic-prof/toggling.js n="1" size="128" depth="16": ./node-with-object-collect: 54.967 ./node-without-object-collect: 3256 ... -98.31%
perf-basic-prof/toggling.js n="1" size="128" depth="32": ./node-with-object-collect: 30.886 ./node-without-object-collect: 3151 ... -99.02%
perf-basic-prof/toggling.js n="1" size="128" depth="64": ./node-with-object-collect: 23.001 ./node-without-object-collect: 4698 ... -99.51%
perf-basic-prof/toggling.js n="2" size="16" depth="16": ./node-with-object-collect: 92.559 ./node-without-object-collect: 10621 ... -99.13%
perf-basic-prof/toggling.js n="2" size="16" depth="32": ./node-with-object-collect: 87.352 ./node-without-object-collect: 9355.4 .. -99.07%
perf-basic-prof/toggling.js n="2" size="16" depth="64": ./node-with-object-collect: 71.746 ./node-without-object-collect: 8606 .... -99.17%
perf-basic-prof/toggling.js n="2" size="32" depth="16": ./node-with-object-collect: 86.657 ./node-without-object-collect: 8856.4 .. -99.02%
perf-basic-prof/toggling.js n="2" size="32" depth="32": ./node-with-object-collect: 72.948 ./node-without-object-collect: 8580.5 .. -99.15%
perf-basic-prof/toggling.js n="2" size="32" depth="64": ./node-with-object-collect: 69.457 ./node-without-object-collect: 9622.8 .. -99.28%
perf-basic-prof/toggling.js n="2" size="64" depth="16": ./node-with-object-collect: 75.882 ./node-without-object-collect: 9065.7 .. -99.16%
perf-basic-prof/toggling.js n="2" size="64" depth="32": ./node-with-object-collect: 65.372 ./node-without-object-collect: 8600.7 .. -99.24%
perf-basic-prof/toggling.js n="2" size="64" depth="64": ./node-with-object-collect: 54.944 ./node-without-object-collect: 9804.1 .. -99.44%
perf-basic-prof/toggling.js n="2" size="128" depth="16": ./node-with-object-collect: 55.118 ./node-without-object-collect: 8809.4 . -99.37%
perf-basic-prof/toggling.js n="2" size="128" depth="32": ./node-with-object-collect: 35.912 ./node-without-object-collect: 7649.1 . -99.53%
perf-basic-prof/toggling.js n="2" size="128" depth="64": ./node-with-object-collect: 21.996 ./node-without-object-collect: 9441.4 . -99.77%
perf-basic-prof/toggling.js n="4" size="16" depth="16": ./node-with-object-collect: 80.592 ./node-without-object-collect: 13673 ... -99.41%
perf-basic-prof/toggling.js n="4" size="16" depth="32": ./node-with-object-collect: 90.401 ./node-without-object-collect: 14242 ... -99.37%
perf-basic-prof/toggling.js n="4" size="16" depth="64": ./node-with-object-collect: 86.052 ./node-without-object-collect: 18675 ... -99.54%
perf-basic-prof/toggling.js n="4" size="32" depth="16": ./node-with-object-collect: 81.585 ./node-without-object-collect: 21184 ... -99.61%
perf-basic-prof/toggling.js n="4" size="32" depth="32": ./node-with-object-collect: 81.328 ./node-without-object-collect: 18853 ... -99.57%
perf-basic-prof/toggling.js n="4" size="32" depth="64": ./node-with-object-collect: 76.457 ./node-without-object-collect: 19979 ... -99.62%
perf-basic-prof/toggling.js n="4" size="64" depth="16": ./node-with-object-collect: 79.639 ./node-without-object-collect: 19836 ... -99.60%
perf-basic-prof/toggling.js n="4" size="64" depth="32": ./node-with-object-collect: 67.347 ./node-without-object-collect: 12554 ... -99.46%
perf-basic-prof/toggling.js n="4" size="64" depth="64": ./node-with-object-collect: 58.274 ./node-without-object-collect: 18985 ... -99.69%
perf-basic-prof/toggling.js n="4" size="128" depth="16": ./node-with-object-collect: 49.624 ./node-without-object-collect: 18349 .. -99.73%
perf-basic-prof/toggling.js n="4" size="128" depth="32": ./node-with-object-collect: 40.86 ./node-without-object-collect: 18274 ... -99.78%
perf-basic-prof/toggling.js n="4" size="128" depth="64": ./node-with-object-collect: 26.161 ./node-without-object-collect: 18768 .. -99.86%
perf-basic-prof/toggling.js n="8" size="16" depth="16": ./node-with-object-collect: 93.632 ./node-without-object-collect: 37214 ... -99.75%
perf-basic-prof/toggling.js n="8" size="16" depth="32": ./node-with-object-collect: 95.081 ./node-without-object-collect: 41840 ... -99.77%
perf-basic-prof/toggling.js n="8" size="16" depth="64": ./node-with-object-collect: 91.836 ./node-without-object-collect: 25436 ... -99.64%
perf-basic-prof/toggling.js n="8" size="32" depth="16": ./node-with-object-collect: 90.011 ./node-without-object-collect: 35101 ... -99.74%
perf-basic-prof/toggling.js n="8" size="32" depth="32": ./node-with-object-collect: 83.497 ./node-without-object-collect: 39130 ... -99.79%
perf-basic-prof/toggling.js n="8" size="32" depth="64": ./node-with-object-collect: 75.492 ./node-without-object-collect: 36290 ... -99.79%
perf-basic-prof/toggling.js n="8" size="64" depth="16": ./node-with-object-collect: 80.97 ./node-without-object-collect: 40384 .... -99.80%
perf-basic-prof/toggling.js n="8" size="64" depth="32": ./node-with-object-collect: 59.029 ./node-without-object-collect: 33340 ... -99.82%
perf-basic-prof/toggling.js n="8" size="64" depth="64": ./node-with-object-collect: 60.393 ./node-without-object-collect: 25979 ... -99.77%
perf-basic-prof/toggling.js n="8" size="128" depth="16": ./node-with-object-collect: 61.083 ./node-without-object-collect: 36345 .. -99.83%
perf-basic-prof/toggling.js n="8" size="128" depth="32": ./node-with-object-collect: 44.604 ./node-without-object-collect: 37369 .. -99.88%
perf-basic-prof/toggling.js n="8" size="128" depth="64": ./node-with-object-collect: 23.213 ./node-without-object-collect: 39234 .. -99.94%
perf-basic-prof/toggling.js n="16" size="16" depth="16": ./node-with-object-collect: 83.395 ./node-without-object-collect: 90230 .. -99.91%
perf-basic-prof/toggling.js n="16" size="16" depth="32": ./node-with-object-collect: 94.465 ./node-without-object-collect: 72495 .. -99.87%
perf-basic-prof/toggling.js n="16" size="16" depth="64": ./node-with-object-collect: 84.677 ./node-without-object-collect: 75512 .. -99.89%
perf-basic-prof/toggling.js n="16" size="32" depth="16": ./node-with-object-collect: 79.913 ./node-without-object-collect: 50251 .. -99.84%
perf-basic-prof/toggling.js n="16" size="32" depth="32": ./node-with-object-collect: 81.402 ./node-without-object-collect: 73951 .. -99.89%
perf-basic-prof/toggling.js n="16" size="32" depth="64": ./node-with-object-collect: 70.599 ./node-without-object-collect: 69632 .. -99.90%
perf-basic-prof/toggling.js n="16" size="64" depth="16": ./node-with-object-collect: 81.999 ./node-without-object-collect: 75945 .. -99.89%
perf-basic-prof/toggling.js n="16" size="64" depth="32": ./node-with-object-collect: 53.921 ./node-without-object-collect: 77334 .. -99.93%
perf-basic-prof/toggling.js n="16" size="64" depth="64": ./node-with-object-collect: 41.67 ./node-without-object-collect: 74644 ... -99.94%
perf-basic-prof/toggling.js n="16" size="128" depth="16": ./node-with-object-collect: 52.566 ./node-without-object-collect: 71531 . -99.93%
perf-basic-prof/toggling.js n="16" size="128" depth="32": ./node-with-object-collect: 45.462 ./node-without-object-collect: 74448 . -99.94%
perf-basic-prof/toggling.js n="16" size="128" depth="64": ./node-with-object-collect: 24.536 ./node-without-object-collect: 75511 . -99.97%
As we can see, there's a huge drop in performance when collecting objects on enable, which is expected as the first version was almost a no-op, while the second version have to iterate the entire heap to collect objects.
Benchmark code is available here