From 6f3a4690ff427c79c06491b49b42300f458cdfc8 Mon Sep 17 00:00:00 2001 From: Tiago Henriques Date: Wed, 28 Jun 2017 18:26:44 +0200 Subject: [PATCH 1/2] Emit cumulative json reports --- src/lua/empty-test.lua | 40 +++++++++++++++++++++++++++++++++------ src/lua/prime-test.lua | 43 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/lua/empty-test.lua b/src/lua/empty-test.lua index 7be089b..8770b00 100644 --- a/src/lua/empty-test.lua +++ b/src/lua/empty-test.lua @@ -15,10 +15,38 @@ sysbench.cmdline.options = { function event() end -function sysbench.hooks.report_intermediate(stat) +function sysbench.hooks.report_cumulative(stat) local seconds = stat.time_interval - print(string.format("%.0f;%u;%4.2f", - stat.time_total, - stat.threads_running, - stat.events / seconds)) -end \ No newline at end of file + print(string.format([[ +{ + "errors": %4.0f, + "events": %4.0f, + "latency_avg": %4.10f, + "latency_max": %4.10f, + "latency_min": %4.10f, + "latency_pct": %4.10f, + "latency_sum": %4.10f, + "other": %4.0f, + "reads": %4.0f, + "reconnects": %4.0f, + "threads_running": %4.0f, + "time_interval": %4.10f, + "time_total": %4.10f, + "writes": %4.0f +} +]], + stat.errors, + stat.events, + stat.latency_avg, + stat.latency_max, + stat.latency_min, + stat.latency_pct, + stat.latency_sum, + stat.other, + stat.reads, + stat.reconnects, + stat.threads_running, + stat.time_interval, + stat.time_total, + stat.writes)) +end diff --git a/src/lua/prime-test.lua b/src/lua/prime-test.lua index 58cac5c..c97c9e5 100644 --- a/src/lua/prime-test.lua +++ b/src/lua/prime-test.lua @@ -16,22 +16,49 @@ function event() n = 0 for c = 3, sysbench.opt.cpu_max_prime do t = math.sqrt(c) - l = 2 for l = 2, t do if c % l == 0 then break end end - if l > t then + if l and l > t then n = n + 1 end end end -function sysbench.hooks.report_intermediate(stat) +function sysbench.hooks.report_cumulative(stat) local seconds = stat.time_interval - print(string.format("%.0f;%u;%4.2f", - stat.time_total, - stat.threads_running, - stat.events / seconds)) -end \ No newline at end of file + print(string.format([[ +{ + "errors": %4.0f, + "events": %4.0f, + "latency_avg": %4.10f, + "latency_max": %4.10f, + "latency_min": %4.10f, + "latency_pct": %4.10f, + "latency_sum": %4.10f, + "other": %4.0f, + "reads": %4.0f, + "reconnects": %4.0f, + "threads_running": %4.0f, + "time_interval": %4.10f, + "time_total": %4.10f, + "writes": %4.0f +} +]], + stat.errors, + stat.events, + stat.latency_avg, + stat.latency_max, + stat.latency_min, + stat.latency_pct, + stat.latency_sum, + stat.other, + stat.reads, + stat.reconnects, + stat.threads_running, + stat.time_interval, + stat.time_total, + stat.writes)) +end From 009551f4e3209c34dc4df807cbdcf9f4cf7c1e95 Mon Sep 17 00:00:00 2001 From: Tiago Henriques Date: Wed, 28 Jun 2017 18:28:06 +0200 Subject: [PATCH 2/2] Use same defaults as built-in options --- src/lua/empty-test.lua | 4 ++-- src/lua/prime-test.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua/empty-test.lua b/src/lua/empty-test.lua index 8770b00..fbbb862 100644 --- a/src/lua/empty-test.lua +++ b/src/lua/empty-test.lua @@ -7,8 +7,8 @@ sysbench.cmdline.options = { -- the default values for built-in options are currently ignored, see -- https://github.com/akopytov/sysbench/issues/151 ["cpu-max-prime"] = {"CPU maximum prime", 10000}, - ["threads"] = {"Number of threads", 2}, - ["histogram"] = {"Show histogram", "on"}, + ["threads"] = {"Number of threads", 1}, + ["histogram"] = {"Show histogram", "off"}, ["report-interval"] = {"Report interval", 1} } diff --git a/src/lua/prime-test.lua b/src/lua/prime-test.lua index c97c9e5..34eaa48 100644 --- a/src/lua/prime-test.lua +++ b/src/lua/prime-test.lua @@ -7,8 +7,8 @@ sysbench.cmdline.options = { -- the default values for built-in options are currently ignored, see -- https://github.com/akopytov/sysbench/issues/151 ["cpu-max-prime"] = {"CPU maximum prime", 10000}, - ["threads"] = {"Number of threads", 2}, - ["histogram"] = {"Show histogram", "on"}, + ["threads"] = {"Number of threads", 1}, + ["histogram"] = {"Show histogram", "off"}, ["report-interval"] = {"Report interval", 1} }