HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/node_modules/pm2/node_modules/fclone/bench/loopobj.js
'use strict'
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite

let obj = process.env

suite
.add('for in', function() {
  for(let i in obj) {
    let o = obj[i]
  }
})
.add('while --', function() {
  let keys = Object.keys(obj)
  let l = keys.length
  while(l--) {
    let o = obj[keys[l]]
  }
})
.add('while shift', function() {
  let keys = Object.keys(obj)
  let k

  while(k = keys.shift()) {
    let o = obj[k]
  }
})
.on('cycle', function(event) {
  console.log(String(event.target))
})
.on('complete', function() {
  console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run({ 'async': true })