Sin descripción

createNoCodeFunction.js 590B

123456789101112131415161718192021222324252627282930
  1. 'use strict'
  2. var fib = require('./fib')
  3. var max = 100000000
  4. var start = Date.now()
  5. // create a funcion with the typical error
  6. // pattern, that delegates the heavy load
  7. // to something else
  8. function createNoCodeFunction () {
  9. /* eslint no-constant-condition: "off" */
  10. var num = 100
  11. ;(function () {
  12. if (null) {
  13. // do nothing
  14. } else {
  15. fib(num)
  16. }
  17. })()
  18. }
  19. for (var i = 0; i < max; i++) {
  20. createNoCodeFunction()
  21. }
  22. var time = Date.now() - start
  23. console.log('Total time', time)
  24. console.log('Total iterations', max)
  25. console.log('Iteration/s', max / time * 1000)