1 | durations = require './src/index.coffee'
|
2 |
|
3 | watch = durations.stopwatch()
|
4 | console.log "Duration should be zero:", watch.duration().nanos()
|
5 | console.log "Formatted, no time registered: ", watch.duration().format()
|
6 | console.log "Should be same format as above:", watch.format()
|
7 |
|
8 | watch = durations.stopwatch().start()
|
9 | console.log "Duration should be non-zero:", watch.duration().nanos()
|
10 | watch.stop()
|
11 | console.log "Formatted duration, with time: ", watch.duration().format()
|
12 | console.log "Should be same format as above:", watch.format()
|
13 |
|
14 | console.log "Format on creation: ",
|
15 | durations.stopwatch().start().stop().format()
|
16 |
|
17 | action = ->
|
18 | num for num in [1 .. 5000000]
|
19 |
|
20 | actionAsync = (next) ->
|
21 | num for num in [5000000 .. 10000000]
|
22 | next()
|
23 |
|
24 | durations.timeAsync(actionAsync).then((duration) ->
|
25 | console.log "Async timing:", duration.format()
|
26 | )
|
27 |
|
28 | console.log "Sync timing:", durations.time(action).format()
|
29 |
|