]>
Commit | Line | Data |
---|---|---|
f427ee49 A |
1 | #!/usr/local/bin/recon |
2 | ||
3 | local benchrun = require 'benchrun' | |
4 | local perfdata = require 'perfdata' | |
5 | local csv = require 'csv' | |
6 | ||
7 | require 'strict' | |
8 | ||
9 | local kDefaultDuration = 15 | |
10 | local kDefaultSizeMb = 16 | |
11 | ||
12 | local benchmark = benchrun.new { | |
13 | name = 'xnu.madvise', | |
14 | version = 1, | |
15 | arg = arg, | |
16 | modify_argparser = function(parser) | |
17 | parser:argument { | |
18 | name = 'path', | |
19 | description = 'Path to perf_madvise binary' | |
20 | } | |
21 | parser:option{ | |
22 | name = '--duration', | |
23 | description = 'How long, in seconds, to run each iteration', | |
24 | default = kDefaultDuration | |
25 | } | |
26 | parser:option{ | |
27 | name = '--variant', | |
28 | description = 'Which benchmark variant to run (MADV_FREE)', | |
29 | default = 'MADV_FREE', | |
30 | choices = {"MADV_FREE"} | |
31 | } | |
32 | parser:option{ | |
33 | name = '--verbose', | |
34 | description = 'Enable verbose logging', | |
35 | } | |
36 | parser:option{ | |
37 | name = '--size', | |
38 | description = 'Madvise buffer size (MB)', | |
39 | default = kDefaultSizeMb | |
40 | } | |
41 | end | |
42 | } | |
43 | ||
44 | local unit = perfdata.unit.custom('pages/sec') | |
45 | local tests = { | |
46 | path = benchmark.opt.path, | |
47 | } | |
48 | ||
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") | |
52 | end | |
53 | args.echo = true | |
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 | |
63 | }) | |
64 | end | |
65 | end | |
66 | end | |
67 | benchmark.writer:set_primary_metric("Throughput (bytes / CPU second)") | |
68 | ||
69 | benchmark:finish() |