Last active
May 11, 2020 23:54
-
-
Save jpoon/341fd127dc91da4e6167a216fe7554cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sysbench | |
-- you can run this script like this: | |
-- -- $ ./prime-test.lu0a --cpu-max-prime=20000 --threads=8 --report-interval=10 --time=999999999 run | |
sysbench.cmdline.options = { | |
-- the default values for built-in options are currently ignored, see | |
-- https://github.com/akopytov/sysbench/issues/151 | |
["test"] = {"test", "cpu"}, | |
["cpu-max-prime"] = {"CPU maximum prime", 20000}, | |
["threads"] = {"Number of threads", 1}, | |
["report-interval"] = {"Report interval", 1} | |
} | |
function event() | |
local n = 0 | |
for c = 3, sysbench.opt.cpu_max_prime do | |
local t = math.sqrt(c) | |
local isprime = true | |
for l = 2, t do | |
if c % l == 0 then | |
isprime = false | |
break | |
end | |
end | |
if isprime then | |
n = n + 1 | |
end | |
end | |
end | |
function sysbench.hooks.report_intermediate(stat) | |
local curTime = os.time() | |
local seconds = stat.time_interval | |
print(string.format("%s, %4.2f", | |
os.date("%H:%M:%S"), | |
stat.events / seconds)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment