You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
590 B

2 years ago
  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)