Last change
on this file since 76712b2 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 |
|
---|
3 | var reusify = require('../')
|
---|
4 | var fib = require('./fib')
|
---|
5 | var instance = reusify(MyObject)
|
---|
6 | var max = 100000000
|
---|
7 | var start = Date.now()
|
---|
8 |
|
---|
9 | function reuseNoCodeFunction () {
|
---|
10 | var obj = instance.get()
|
---|
11 | obj.num = 100
|
---|
12 | obj.func()
|
---|
13 | obj.num = 0
|
---|
14 | instance.release(obj)
|
---|
15 | }
|
---|
16 |
|
---|
17 | function 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 |
|
---|
31 | for (var i = 0; i < max; i++) {
|
---|
32 | reuseNoCodeFunction()
|
---|
33 | }
|
---|
34 |
|
---|
35 | var time = Date.now() - start
|
---|
36 | console.log('Total time', time)
|
---|
37 | console.log('Total iterations', max)
|
---|
38 | console.log('Iteration/s', max / time * 1000)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.