kiki/coffee/tools/profile.coffee
2016-10-10 18:28:35 +02:00

26 lines
713 B
CoffeeScript

# 00000000 00000000 0000000 00000000 000 000 00000000
# 000 000 000 000 000 000 000 000 000 000
# 00000000 0000000 000 000 000000 000 000 0000000
# 000 000 000 000 000 000 000 000 000
# 000 000 000 0000000 000 000 0000000 00000000
now = require 'performance-now'
log = require './log'
start = undefined
s_msg = undefined
profile = (msg) ->
if start? and s_msg.length
ms = (now()-start).toFixed 0
if ms > 1000
log "#{s_msg} in #{(ms/1000).toFixed(3)} sec"
else
log "#{s_msg} in #{ms} ms"
start = now()
s_msg = msg
module.exports = profile