summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-04 22:02:39 +0800
committerruki <[email protected]>2025-10-04 22:02:39 +0800
commitf5cb55bc3ea8333c64e45bdbae2890b6ca1cd3c4 (patch)
tree9588983e68bff9368e43dd71d619c7723335cd13
parent05525e2450c8af5344bd1ace78d4b532955de76c (diff)
add runjobs benchmark
-rw-r--r--core/src/xmake/os/getenvs.c2
-rw-r--r--tests/benchmarks/async/runjobs.lua33
2 files changed, 33 insertions, 2 deletions
diff --git a/core/src/xmake/os/getenvs.c b/core/src/xmake/os/getenvs.c
index 23fdf677e..7e6d611d6 100644
--- a/core/src/xmake/os/getenvs.c
+++ b/core/src/xmake/os/getenvs.c
@@ -182,7 +182,5 @@ tb_int_t xm_os_getenvs(lua_State* lua)
}
}
#endif
-
- // ok
return 1;
}
diff --git a/tests/benchmarks/async/runjobs.lua b/tests/benchmarks/async/runjobs.lua
new file mode 100644
index 000000000..937697413
--- /dev/null
+++ b/tests/benchmarks/async/runjobs.lua
@@ -0,0 +1,33 @@
+import("async.runjobs")
+
+function test_run(total, comax)
+ local f = function () end
+ local t1 = os.mclock()
+ runjobs("test", f, {total = total, comax = comax})
+ t1 = os.mclock() - t1
+
+ local n = total
+ local t2 = os.mclock()
+ while n ~= 0 do
+ f()
+ n = n - 1
+ end
+ t2 = os.mclock() - t2
+ print("runjobs(%d/%d): %d ms, plain: %d ms", total, comax, t1, t2)
+end
+
+function test_run_proc(total, comax)
+ local f = function () os.runv(os.programfile(), {"--version"}) end
+ local t1 = os.mclock()
+ runjobs("test", f, {total = total, comax = comax})
+ t1 = os.mclock() - t1
+ print("runjobs_proc(%d/%d): %d ms", total, comax, t1)
+end
+
+function main()
+ test_run(10000, 1)
+ test_run(10000, 10)
+ test_run(10000, 100)
+ test_run_proc(1000, 10)
+end
+