mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
"cake bench" now shows total time spent
This commit is contained in:
parent
1a9a48c5f2
commit
bcbf9f7dfd
1 changed files with 8 additions and 6 deletions
14
Cakefile
14
Cakefile
|
@ -124,17 +124,19 @@ task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
|
|||
task 'bench', 'quick benchmark of compilation time', ->
|
||||
{Rewriter} = require './lib/rewriter'
|
||||
co = sources.map((name) -> fs.readFileSync name).join '\n'
|
||||
fmt = (ms) -> " : #{bold}#{ " #{ms}".slice -4 }#{reset}[ms]"
|
||||
total = 0
|
||||
now = Date.now()
|
||||
time = ->
|
||||
bold + (' ' + -(now - now = Date.now())).slice(-5) + reset + '[ms]'
|
||||
time = -> total += ms = -(now - now = Date.now()); fmt ms
|
||||
tokens = CoffeeScript.tokens co, rewrite: false
|
||||
console.log "Lex :#{time()} (#{tokens.length} tokens)"
|
||||
console.log "Lex #{time()} (#{tokens.length} tokens)"
|
||||
tokens = new Rewriter().rewrite tokens
|
||||
console.log "Rewrite :#{time()} (#{tokens.length} tokens)"
|
||||
console.log "Rewrite#{time()} (#{tokens.length} tokens)"
|
||||
nodes = CoffeeScript.nodes tokens
|
||||
console.log "Parse :#{time()}"
|
||||
console.log "Parse #{time()}"
|
||||
js = nodes.compile bare: true
|
||||
console.log "Compile :#{time()} (#{js.length} bytes)"
|
||||
console.log "Compile#{time()} (#{js.length} chars)"
|
||||
console.log "TOTAL #{ fmt total }"
|
||||
|
||||
task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
|
||||
exec "cat #{ sources.join(' ') } | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue