MaxScript 模拟Python 的装饰器

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"
上一篇:tensorflow2.0入门(1):GPU版环境搭建Win10+Cuda10+cudnn7.6.3


下一篇:Python学习笔记:利用timeit计算函数调用耗时