diff options
author | iximeow <me@iximeow.net> | 2024-04-01 23:44:56 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2024-04-01 23:45:28 -0700 |
commit | 9dd2f26670a706db6227e3aa5301f383bf603419 (patch) | |
tree | f053ac8b05fc55e3c3a0d960c10fdb52145ea9c0 | |
parent | 9a120cc76a49e5aadb0454f3ec4e89a6bff15a5d (diff) |
add perf testing to mainline goodfile
-rw-r--r-- | goodfile | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -63,3 +63,52 @@ Build.run({"./bench-yaxpeax-no-fmt", "20", "0x400", "0x2460400", "../../input/xu bench_end = Build.now_ms() Build.metric("no-fmt runtime (ms)", bench_end - bench_start) + +-- perf + +if Build.environment.has("perf") then + perf_setting = Build.check_output({"cat", "/proc/sys/kernel/perf_event_paranoid"}) + -- TODO: roll this up into some perf tools in the lua env. for now, if perf + -- event paranoid is >2 then we'll probably just fail the build trying and + -- failing to run perf. + perf_out = Build.check_output({"perf", "stat", "-x", ";", "-e", "cycles,instructions", "./bench-yaxpeax-no-fmt", "20", "0x400", "0x2460400", "../../input/xul.dll"}, {cwd="disas-bench/bench/yaxpeax"}) + + measurements = {} + + for count, unit, name in perf_out.stderr:gmatch("([^;]*);([^;]*);([^;]*)[^\n]*\n?") do + measurements[name] = tonumber(count) + end + + insts, good, bad, ms = perf_out.stdout:match("Disassembled (%d*) instructions %((%d*) valid, (%d*) bad%), (%d*) ms") + + measurements["decoded"] = tonumber(insts) + measurements["elapsed_ms"] = tonumber(ms) + + ipc = measurements["instructions:u"] / measurements["cycles:u"] + Build.metric("no-fmt IPC", string.format("%.3f", ipc)) + inst_per_decode = measurements["instructions:u"] / measurements["decoded"] + Build.metric("no-fmt instructions/decode", string.format("%.1f", inst_per_decode)) + ms_per_decode = measurements["elapsed_ms"] / measurements["decoded"] + Build.metric("no-fmt ns/decode", string.format("%.2f", ms_per_decode * 1000000)) + + + perf_out = Build.check_output({"perf", "stat", "-x", ";", "-e", "cycles,instructions", "./bench-yaxpeax-fmt", "20", "0x400", "0x2460400", "../../input/xul.dll"}, {cwd="disas-bench/bench/yaxpeax"}) + + measurements = {} + + for count, unit, name in perf_out.stderr:gmatch("([^;]*);([^;]*);([^;]*)[^\n]*\n?") do + measurements[name] = tonumber(count) + end + + insts, good, bad, ms = perf_out.stdout:match("Disassembled (%d*) instructions %((%d*) valid, (%d*) bad%), (%d*) ms") + + measurements["decoded"] = tonumber(insts) + measurements["elapsed_ms"] = tonumber(ms) + + ipc = measurements["instructions:u"] / measurements["cycles:u"] + Build.metric("fmt IPC", string.format("%.3f", ipc)) + inst_per_decode = measurements["instructions:u"] / measurements["decoded"] + Build.metric("fmt instructions/decode", string.format("%.1f", inst_per_decode)) + ms_per_decode = measurements["elapsed_ms"] / measurements["decoded"] + Build.metric("fmt ns/decode", string.format("%.2f", ms_per_decode * 1000000)) +end |