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:
590 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | var fib = require('./fib')
|
---|
| 4 | var max = 100000000
|
---|
| 5 | var start = Date.now()
|
---|
| 6 |
|
---|
| 7 | // create a funcion with the typical error
|
---|
| 8 | // pattern, that delegates the heavy load
|
---|
| 9 | // to something else
|
---|
| 10 | function createNoCodeFunction () {
|
---|
| 11 | /* eslint no-constant-condition: "off" */
|
---|
| 12 | var num = 100
|
---|
| 13 |
|
---|
| 14 | ;(function () {
|
---|
| 15 | if (null) {
|
---|
| 16 | // do nothing
|
---|
| 17 | } else {
|
---|
| 18 | fib(num)
|
---|
| 19 | }
|
---|
| 20 | })()
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | for (var i = 0; i < max; i++) {
|
---|
| 24 | createNoCodeFunction()
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | var time = Date.now() - start
|
---|
| 28 | console.log('Total time', time)
|
---|
| 29 | console.log('Total iterations', max)
|
---|
| 30 | console.log('Iteration/s', max / time * 1000)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.