diff --git a/Test/NumpyTest/App/test_numpy.vp b/Test/NumpyTest/App/test_numpy.vp index 1b25d0f..e3aad42 100644 --- a/Test/NumpyTest/App/test_numpy.vp +++ b/Test/NumpyTest/App/test_numpy.vp @@ -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()