usagizmo
12/30/2017 - 5:09 AM

Timer closure for benchmark

const timer = function (name) {
  const start = new Date()
  return {
    stop () {
      const end = new Date()
      const time = end.getTime() - start.getTime()
      console.log('Timer:', name, 'finished in', time, 'ms')
    }
  }
}