fn timeit func =
(
global tmp_func = func
fn warpper =
(
start_time = timeStamp()
tmp_func()
end_time = timeStamp()
print ("用时:" + (end_time - start_time) as string + "ms")
)
return warpper
)
fn foo =
(
for i = 1 to 5 do sleep 0.01
)
foo = timeit foo
foo()
timeit()
foo()
warpper()
"用时:55ms"
"用时:55ms"