#Requires AutoHotkey v2.0 Deco(inFn) ; 给函数加了默认参数 ; Deco(inFn, outFn) inFn(2, 54) inFn(504, 54) Sleep 3000 ;~ 感谢空神的装饰器源码和liuyukuan的高精度测时源码 Deco(insideFunc, outsideFunc := outFn) { fc := insideFunc.Call insideFunc.DefineProp('Call',{ call: (args*) => outsideFunc(fc, args*) }) } inFn(a, b) { Loop 100000*a b := 1 return a + b } outFn(fn, args*) { c := 0 DllCall("QueryPerformanceFrequency", "int64*", &c) QuadPart := c DllCall("QueryPerformanceCounter", "int64*", &c) CounterBefore := c r := fn(args*) DllCall("QueryPerformanceCounter", "int64*", &c) CounterAfter := c costTime := '耗时:' Round((CounterAfter - CounterBefore)/QuadPart*1000, 1) ' ms.' ToolTip costTime }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)