|
1 | 1 | # TickTock |
2 | 2 |
|
3 | | -This module provides `tick()`, `tock()`, and `tok()` functions. |
4 | | - |
5 | | -They're similar to the `tic()`, `toc()`, and `toq()` functions that you might find in MATLAB and |
6 | | -similar software. |
| 3 | +This module provides `tick()`, `tock()`, and `tok()` functions. They're similar to the `tic()`, `toc()`, and `toq()` functions that you might find in MATLAB and |
| 4 | +similar software. There are also `lap()` and `peek()` functions that reveal the state of the current timer without stopping it. |
7 | 5 |
|
8 | 6 | **Don't use these for timing code execution!** Julia provides much better facilities for |
9 | 7 | measuring performance, ranging from the `@time` and `@elapsed` macros to packages such as [BenchmarkTools.jl](https://github.com/JuliaCI/BenchmarkTools.jl). (And remember, don't |
10 | | -time Julia code running in global scope!) |
| 8 | +time Julia code running in global scope!) The [TimerOutputs.jl](https://github.com/KristofferC/TimerOutputs.jl) package provides tools for timing different sections of a program. |
11 | 9 |
|
12 | | -This code used to live in Julia Base in the `tic()`, `toc()`, and `toq()` functions (in base/util.jl). They were deprecated in GitHub issue [17046](https://github.com/JuliaLang/julia/issues/17046). |
| 10 | +## Functions |
13 | 11 |
|
14 | | -The [TimerOutputs.jl](https://github.com/KristofferC/TimerOutputs.jl) package provides tools for timing different sections of a program. |
| 12 | +- `tick()` start counting |
| 13 | +- `tock()` stop counting show total elapsed time |
| 14 | +- `tok()` stop counting return seconds |
| 15 | +- `peek()` continue counting, return elapsed seconds |
| 16 | +- `lap()` continue counting, show total elapsed time |
15 | 17 |
|
16 | | -## Example |
| 18 | +## Suggestions for use |
17 | 19 |
|
18 | | -```julia |
19 | | -julia-0.6> using TickTock |
| 20 | +You can: |
20 | 21 |
|
21 | | -julia-0.6> tick() |
22 | | -INFO: Started timer at 2017-12-12T09:33:00.363. |
| 22 | +- time how long a phone call takes without leaving the Julia REPL |
23 | 23 |
|
| 24 | +``` |
| 25 | +julia-0.6> using TickTock |
| 26 | +julia-0.6> tick() |
| 27 | +INFO: Started timer: 2017-12-13T22:30:59.632. |
24 | 28 | julia-0.6> tock() |
25 | | -INFO: Time taken: 149.427977832 |
26 | | -INFO: 2 minutes, 29 seconds, 427 milliseconds |
| 29 | +INFO: 55.052638936 ms: 55 seconds, 52 milliseconds |
27 | 30 | ``` |
28 | 31 |
|
29 | | -To return the elapsed time in seconds, use `tok()`: |
| 32 | +- see whether your cup of tea's brewed for the right length of time: |
30 | 33 |
|
31 | | -```julia |
| 34 | +julia-0.6> tick() |
| 35 | +INFO: Started timer: 2017-12-13T22:34:03.78. |
| 36 | +julia-0.6> lap() |
| 37 | +INFO: 72.625839832 ms: 1 minute, 12 seconds, 625 milliseconds |
| 38 | +julia-0.6> lap() |
| 39 | +INFO: 266.053953749 ms: 4 minutes, 26 seconds, 53 milliseconds |
| 40 | +julia-0.6> lap() |
| 41 | +INFO: 285.314459174 ms: 4 minutes, 45 seconds, 314 milliseconds |
| 42 | +``` |
| 43 | +
|
| 44 | +- see how many seconds you held your breath for: |
| 45 | +
|
| 46 | +``` |
32 | 47 | julia-0.6> tick() |
33 | 48 | INFO: Started timer at 2017-12-12T09:17:45.504. |
34 | 49 |
|
35 | 50 | julia-0.6> tok() |
36 | 51 | 287.841546621 |
37 | 52 | ``` |
38 | 53 |
|
| 54 | +You should not: |
| 55 | +
|
| 56 | +- measure performance of Julia code |
| 57 | +
|
| 58 | +## Acknowledgements |
| 59 | +
|
| 60 | +This code used to live in Julia Base in the `tic()`, `toc()`, and `toq()` functions (in base/util.jl). They were deprecated in GitHub issue [17046](https://github.com/JuliaLang/julia/issues/17046). |
| 61 | +
|
39 | 62 | [](https://travis-ci.org/cormullion/TickTock.jl) |
40 | 63 |
|
41 | 64 | [](https://coveralls.io/github/cormullion/TickTock.jl?branch=master) |
|
0 commit comments