Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

reuseNoCodeFunction.js 713B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict'
  2. var reusify = require('../')
  3. var fib = require('./fib')
  4. var instance = reusify(MyObject)
  5. var max = 100000000
  6. var start = Date.now()
  7. function reuseNoCodeFunction () {
  8. var obj = instance.get()
  9. obj.num = 100
  10. obj.func()
  11. obj.num = 0
  12. instance.release(obj)
  13. }
  14. function MyObject () {
  15. this.next = null
  16. var that = this
  17. this.num = 0
  18. this.func = function () {
  19. /* eslint no-constant-condition: "off" */
  20. if (null) {
  21. // do nothing
  22. } else {
  23. fib(that.num)
  24. }
  25. }
  26. }
  27. for (var i = 0; i < max; i++) {
  28. reuseNoCodeFunction()
  29. }
  30. var time = Date.now() - start
  31. console.log('Total time', time)
  32. console.log('Total iterations', max)
  33. console.log('Iteration/s', max / time * 1000)