forked from jankabatek/statapack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTICTOC.do
59 lines (42 loc) · 1.06 KB
/
TICTOC.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
********************************************************************************
********************************************************************************
* TICTOC is a Matlab-style timer, free of all that useless syntax
* INPUT: OPTIONAL: anylist = number for
*
* OUTPUT: time
*
* FORMAT: TIC 1
* TOC 1
*[email protected], 07/2016, (c)----------------------*
capture program drop TIC
program define TIC
syntax [anything]
cap confirm number `anything'
if !_rc {
di as err "Clock No. `anything' is turned on!"
}
else {
local anything = 10
}
timer clear `anything'
timer on `anything'
end
capture program drop TOC
program define TOC
syntax [anything]
cap confirm number `anything'
if !_rc {
di as err "Clock No. `anything' is turned off!"
}
else {
local anything = 10
}
timer off `anything'
qui timer list `anything'
if r(t1)<300 {
di as err "Elapsed time: " r(t`anything') " sec"
}
else {
di as err "Elapsed time: " r(t`anything') " sec, =" r(t`anything')/60 " mins"
}
end