-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Description
Chunk 2 fails if I enclose chunk 1 in a do block.
@timeit "chunk 1" begin
local var1 = func1()
local var2 = func2()
local var3 = func3()
end
@timeit "chunk 2" begin
compute_with(var1, var2, var3)
end
with_timer("chunk 3") do
... lots of other code that uses var1, var2, and var3
endIt'd be nice if I could sometimes time things without a do block:
# code chunk 1
local timer = start_timing!(t, "chunk 1")
local var1 = func1()
local var2 = func2()
local var3 = func3()
stop_timing!(timer)
@timeit "chunk 2" begin
compute_with(var1, var2, var3)
end
with_timer("chunk 3") do
... lots of other code that uses var1, var2, and var3
endYou could do it like below but separate timers are nicer because otherwise you have to restructure your code simply because you are timing it and large numbers of variables make it even more awkward...
local var1, var2, var3 = with_timer("chunk1") do
func1(), func2(), func3()
endFor throws, if start_timing! happens to be within an outer with_timer block and there's a throw before the stop_timing! call occurs, the outer timing block can clean up the mess.
Metadata
Metadata
Assignees
Labels
No labels