]> git.saurik.com Git - apple/xnu.git/blame - tests/vm/perf_madvise.lua
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tests / vm / perf_madvise.lua
CommitLineData
f427ee49
A
1#!/usr/local/bin/recon
2
3local benchrun = require 'benchrun'
4local perfdata = require 'perfdata'
5local csv = require 'csv'
6
7require 'strict'
8
9local kDefaultDuration = 15
10local kDefaultSizeMb = 16
11
12local 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
44local unit = perfdata.unit.custom('pages/sec')
45local tests = {
46 path = benchmark.opt.path,
47}
48
49local args = {benchmark.opt.path, benchmark.opt.variant, benchmark.opt.duration, benchmark.opt.size}
50if benchmark.opt.verbose then
51 table.insert(args, "-v")
52end
53args.echo = true
54for 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
66end
67benchmark.writer:set_primary_metric("Throughput (bytes / CPU second)")
68
69benchmark:finish()