Hello,
zpu-bench is the first Zig program that I have written; it was a lot of fun! I have previously implemented a similar program in a combination of Python and C, but this new cleanroom implementation in Zig is self-contained. More polishing is required, but as a first cut this version is stable and useful.
Zig function std.Thread.getCpuCount() reports that my laptop has 4 CPUs. But I also know that it is a dual core processor with hyper-threading enable. If it was a 4 core processor with hyper-threading disabled, Zig would also report the CPU count as 4. However the ability to execute tasks in parallel is vastly different between these two computers. The first computer has a degree of parallism (DOP) of 2 and the latter a DOP of 4.
zpu-bench v0.0.3
CPU = 4
COUNTER_I64 = 43007015647
DURATION_MS = 14975
DOP = 2.003
real 0m53.167s
user 2m16.139s
sys 0m0.152s
Github repo: GitHub - wfouche/zpu-bench