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