test(NumpyTest): c.Timer() 改为 timer_sec()(GetTickCount64), 修复链接 undefined symbol: Timer
c.Timer() 无编译器支持(TPC/TPV 均无该内建), bench_numpy_perf 链接期 undefined; 改用 Win32 单调时钟
This commit is contained in:
1 parent
a641cbff63
commit
995faf8a9c
1 file changed
+15
-6
@@ -5,6 +5,7 @@ from stdlib import calloc, free
|
||||
import string
|
||||
import vipermath
|
||||
import memhub
|
||||
import w32.win32base
|
||||
import t, c
|
||||
|
||||
# ============================================================
|
||||
@@ -66,6 +67,14 @@ def section_footer():
|
||||
printf("+--------------------------------------------+\n")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Timer: 单调时钟(GetTickCount64 毫秒 → 秒)
|
||||
# 原 c.Timer() 无编译器支持(TPC/TPV 均无),改用 Win32 API
|
||||
# ============================================================
|
||||
def timer_sec() -> t.CDouble:
|
||||
return t.CDouble(w32.win32base.GetTickCount64()) / t.CDouble(1000.0)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Utility: quick array creation
|
||||
# ============================================================
|
||||
@@ -947,33 +956,33 @@ def bench_numpy_perf():
|
||||
i += 1
|
||||
|
||||
# add benchmark
|
||||
t0: t.CDouble = c.Timer()
|
||||
t0: t.CDouble = timer_sec()
|
||||
j: t.CInt = 0
|
||||
while j < ITERS:
|
||||
r: numpy.ndarray[t.CDouble] | t.CPtr = a + b
|
||||
r.delete()
|
||||
j += 1
|
||||
t1: t.CDouble = c.Timer()
|
||||
t1: t.CDouble = timer_sec()
|
||||
printf(" ADD: %.1f ms\n", (t1 - t0) * t.CDouble(1000.0))
|
||||
|
||||
# mul benchmark
|
||||
t0 = c.Timer()
|
||||
t0 = timer_sec()
|
||||
j = 0
|
||||
while j < ITERS:
|
||||
r2: numpy.ndarray[t.CDouble] | t.CPtr = a * b
|
||||
r2.delete()
|
||||
j += 1
|
||||
t1 = c.Timer()
|
||||
t1 = timer_sec()
|
||||
printf(" MUL: %.1f ms\n", (t1 - t0) * t.CDouble(1000.0))
|
||||
|
||||
# sqrt benchmark
|
||||
t0 = c.Timer()
|
||||
t0 = timer_sec()
|
||||
j = 0
|
||||
while j < ITERS:
|
||||
r3: numpy.ndarray[t.CDouble] | t.CPtr = numpy.np_sqrt(a)
|
||||
r3.delete()
|
||||
j += 1
|
||||
t1 = c.Timer()
|
||||
t1 = timer_sec()
|
||||
printf(" SQRT: %.1f ms\n", (t1 - t0) * t.CDouble(1000.0))
|
||||
|
||||
a.delete()
|
||||
|
||||
Reference in new issue
Block a user