3 local benchrun = require 'benchrun'
4 local perfdata = require 'perfdata'
5 local csv = require 'csv'
9 local kDefaultDuration = 15
10 local kDefaultSizeMb = 16
12 local benchmark = benchrun.new {
16 modify_argparser = function(parser)
19 description = 'Path to perf_madvise binary'
23 description = 'How long, in seconds, to run each iteration',
24 default = kDefaultDuration
28 description = 'Which benchmark variant to run (MADV_FREE)',
29 default = 'MADV_FREE',
30 choices = {"MADV_FREE"}
34 description = 'Enable verbose logging',
38 description = 'Madvise buffer size (MB)',
39 default = kDefaultSizeMb
44 local unit = perfdata.unit.custom('pages/sec')
46 path = benchmark.opt.path,
49 local args = {benchmark.opt.path, benchmark.opt.variant, benchmark.opt.duration, benchmark.opt.size}
50 if benchmark.opt.verbose then
51 table.insert(args, "-v")
54 for out in benchmark:run(args) do
55 local result = out:match("-----Results-----\n(.*)")
56 benchmark:assert(result, "Unable to find result data in output")
57 local data = csv.openstring(result, {header = true})
58 for field in data:lines() do
59 for k, v in pairs(field) do
60 benchmark.writer:add_value(k, unit, tonumber(v), {
61 [perfdata.larger_better] = true,
62 variant = benchmark.opt.variant
67 benchmark.writer:set_primary_metric("Throughput (bytes / CPU second)")