forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.j
38 lines (29 loc) · 624 Bytes
/
util.j
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
# shell
ls() = system("ls")
catfile(file::String) = system(strcat("cat ", file))
# timing
clock() = ccall(:clock_now, Float64, ())
_TIMERS = ()
function tic()
t0 = clock()
global _TIMERS = (t0, _TIMERS)
return t0
end
function _toc(noisy)
t1 = clock()
global _TIMERS
if is(_TIMERS,())
error("toc() without tic()")
end
t0 = _TIMERS[1]
_TIMERS = _TIMERS[2]
t = t1-t0
if noisy
print("elapsed time: ", t, " sec\n")
end
t
end
qtoc() = _toc(false)
toc() = _toc(true)
macro qtime(ex); :(tic(); $ex; qtoc()); end
macro time(ex); :(tic(); $ex; toc()); end