Skip to content

Commit

Permalink
filter benchmarks by looped
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpal committed May 28, 2024
1 parent f7b1b09 commit af7bc48
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
23 changes: 14 additions & 9 deletions infra/nightly-resources/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,21 @@ function selectAllModes(enabled) {
refreshView();
}

function selectAllBenchmarks(enabled) {
function selectAllBenchmarks(enabled, category) {
const checkboxContainer = document.getElementById("benchmarkCheckboxes");
Array.from(checkboxContainer.getElementsByTagName("input")).forEach(
(checkbox) => {
checkbox.checked = enabled;
enabled
? GLOBAL_DATA.enabledBenchmarks.add(checkbox.id)
: GLOBAL_DATA.enabledBenchmarks.delete(checkbox.id);
},
);
let checkboxes = Array.from(checkboxContainer.getElementsByTagName("input"));
if (category === "looped") {
const loopedBenchmarks = new Set(
GLOBAL_DATA.currentRun.filter((x) => x.looped).map((x) => x.benchmark),
);
checkboxes = checkboxes.filter((x) => loopedBenchmarks.has(x.id));
}
checkboxes.forEach((checkbox) => {
checkbox.checked = enabled;
enabled
? GLOBAL_DATA.enabledBenchmarks.add(checkbox.id)
: GLOBAL_DATA.enabledBenchmarks.delete(checkbox.id);
});
refreshView();
}

Expand Down
7 changes: 5 additions & 2 deletions infra/nightly-resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ <h2>Profile</h2>
<div class="filters">
<div>
<p>Benchmarks</p>
<button onclick="selectAllBenchmarks(true)">Select All</button>
<button onclick="selectAllBenchmarks(false)">Select None</button>
<button onclick="selectAllBenchmarks(true, 'all')">Select All</button>
<button onclick="selectAllBenchmarks(false, 'all')">Deselect All</button>
<br />
<button onclick="selectAllBenchmarks(true, 'looped')">Select All Looped</button>
<button onclick="selectAllBenchmarks(false, 'looped')">Deselect All Looped</button>
</div>
<div id="benchmarkCheckboxes"></div>
</div>
Expand Down
15 changes: 12 additions & 3 deletions infra/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,21 @@ def should_have_llvm_ir(runMethod):
]

# aggregate all profile info into a single json array.
def aggregate(compile_times, bench_times):
def aggregate(compile_times, bench_times, looped):
res = []

for path in sorted(compile_times.keys()):
name = path.split("/")[-2]
runMethod = path.split("/")[-1]
result = {"runMethod": runMethod, "benchmark": name, "hyperfine": bench_times[path], "compileTime": compile_times[path]}
result = {"runMethod": runMethod, "benchmark": name, "hyperfine": bench_times[path], "compileTime": compile_times[path], "looped": looped[name]}

res.append(result)
return res

def is_looped(bril_file):
with open(bril_file) as f:
txt = f.read()
return "orig_main" in txt

if __name__ == '__main__':
# expect two arguments
Expand All @@ -138,6 +142,11 @@ def aggregate(compile_times, bench_times):
else:
profiles = [bril_dir]

looped = {}
for profile in profiles:
name = profile.split("/")[-1][:-len(".bril")]
looped[name] = is_looped(profile)

to_run = []
index = 0
total = len(profiles) * len(treatments)
Expand Down Expand Up @@ -181,7 +190,7 @@ def aggregate(compile_times, bench_times):
(path, _bench_data) = res
bench_data[path] = _bench_data

nightly_data = aggregate(compile_times, bench_data)
nightly_data = aggregate(compile_times, bench_data, looped)
with open(f"{DATA_DIR}/profile.json", "w") as profile:
json.dump(nightly_data, profile, indent=2)

Expand Down

0 comments on commit af7bc48

Please sign in to comment.