-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtic.lua
More file actions
42 lines (31 loc) · 723 Bytes
/
Copy pathtic.lua
File metadata and controls
42 lines (31 loc) · 723 Bytes
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
require 'sys'
--[[ usage: (like matlab):
-- usage 1: (simple usage for a single timer)
tic
...
t = toc
-- usage 2: (multiple timers running independently)
t1 = tic
...
t2 = tic
...
tElapsed1 = toc(t1)
...
tElapsed2 = toc(t2)
--]]
tic = function()
--__default_timer = torch.Timer()
__tic_toc_startTime__ = sys.clock()
return __tic_toc_startTime__
end
toc = function(tStart)
--time_elapsed_t = __default_timer:time()
if tStart and type(tStart) ~= 'number' then
error('Input must be a number or nil')
end
if not tStart then
tStart = __tic_toc_startTime__
end
local timeElapsed_sec = sys.clock() - tStart
return timeElapsed_sec
end