-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using custom report formats with embedded tests #141
Comments
No, it's not currently possible. For the future major release, I'm planning to convert all embedded benchmarks to Lua to allow all benchmarks use custom reports and other features, but at the same time have the event loop itself implemented in C to avoid LuaJIT overhead for those benchmarks where it's critical, like the CPU one. I'm going to keep this issue open as a feature request. |
@kimh came here with exactly the same question. Did you end up implementing your own event function implementing the cpu test? Or did you manage to use the FFI to call the C code from src/tests/cpu/sb_cpu.c? |
@TiagoCH unfortunately most functions in sb_cpu.c are static, so using FFI to call them would not work without modifications to C code. It would probably be not too hard to reimplement Actually, just having an empty |
Thanks for the tip, I'll try that the empty event function together with CSV output. I love the ease of use of sysbench, but manually scraping the data from the output into something I can use in Excel is a major PITA. |
I create the following empty_test.lua using an empty event function: #!/usr/bin/env sysbench
sysbench.cmdline.options = {
["cpu-max-prime"] = {"CPU maximum prime", 10000},
["threads"] = {"Number of threads", 2},
["histogram"] = {"Show histogram", "on"},
["report-interval"] = {"Report interval", 1}
}
function event()
end
function sysbench.hooks.report_intermediate(stat)
local seconds = stat.time_interval
print(string.format("%.0f;%u;%4.2f",
stat.time_total,
stat.threads_running,
stat.events / seconds))
end I can then run it like this: ./empty-test.lua --cpu-max-prime=20000 --threads=8 --histogram --report-interval=1 run |
Unfortunately, if I try to run it with the default arguments specified in sysbench.cmdline.options, the default values are ignored. What am I doing wrong? |
By the way, this is my attempt to convert the prime test from cpu_execute_test() into lua: #!/usr/bin/env sysbench
sysbench.cmdline.options = {
["cpu-max-prime"] = {"CPU maximum prime", 10000},
["threads"] = {"Number of threads", 2},
["histogram"] = {"Show histogram", "on"},
["report-interval"] = {"Report interval", 1}
}
function event()
n = 0
for c = 3, 9999 do
t = math.sqrt(c)
l = 2
for l = 2, t do
if c % l == 0 then
break
end
end
if l > t then
n = n + 1
end
end
end
function sysbench.hooks.report_intermediate(stat)
local seconds = stat.time_interval
print(string.format("%.0f;%u;%4.2f",
stat.time_total,
stat.threads_running,
stat.events / seconds))
end |
That is currently not possible, sorry. I created #151 to fix it. |
Looks good! |
Great, I was wondering what the syntax for accessing the arguments was - this is my very first hour doing lua :-) In the meantime I tried comparing the sysbench cpu test with this first lua implementation, and was surprised by the results. The report shows two times as many events for the lua version as for the C version. Since I don't think lua can be two times faster than C, there must be a catch somewhere. Any ideas? Here's the C test:
And here is the lua test:
(EDIT: I was ignoring the sysbench.opt.cpu_max_prime argument, as you noted. Once I fixed that, the lua version is just two times faster than the C version. Still surprising.) |
OK, 3 things:
l = 2
for l = 2, t do
if c % l == 0 then
break
end
end
if l > t then
n = n + 1
end The But that is a minor thing, it verified it does not affect performance.
The master sysbench branch support the |
+1 for this issue. I'd like to automate running cpu/mem tests across thousands of boxes weekly/at provision time and post the result json to a central DB/Solr for analysis. Being able to emit native test results in json would make this way easier. |
Is it possible to report with json format with embedded tests such as
cpu
? I found that I can use json reporter withsysbench.hooks.report_cumulative = sysbench.report_json
in a custom lua script but then I have to define my ownevent
function.Is it possible to only change a formatter with embedded tests?
The text was updated successfully, but these errors were encountered: