source: trip-planner-front/node_modules/reusify/benchmarks/reuseNoCodeFunction.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 713 bytes
Line 
1'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)
Note: See TracBrowser for help on using the repository browser.