-
Notifications
You must be signed in to change notification settings - Fork 333
Format benchmarks #10550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sarahchen6
wants to merge
18
commits into
master
Choose a base branch
from
sarahchen6/migrate-benchmarks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Format benchmarks #10550
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5b5cc66
Remove local benchmarks
sarahchen6 8a3964d
Attempt bringing benchmarking-platform scripts over
sarahchen6 7309e39
Simplify report formatting and PR comment posting
sarahchen6 6d6836c
Merge branch 'master' into sarahchen6/migrate-benchmarks
sarahchen6 eb17915
Fix baseline-commit script
sarahchen6 e87be8f
Try fixing merge-base retrieval logic
sarahchen6 1237b0d
Debug merge base logic
sarahchen6 e61f806
Add debug for merge base logic
sarahchen6 77336f9
Try using authanywhere again
sarahchen6 40bffac
Test all benchmarks now
sarahchen6 1972ad5
Add debug lines and fix baseline info path
sarahchen6 a8e6254
Test only startup
sarahchen6 8a365b6
Try fixing debug lines...
sarahchen6 040780d
Use BTI private token for comparison jobs
sarahchen6 eeabe09
Use grep
sarahchen6 8db8d18
Merge branch 'master' into sarahchen6/migrate-benchmarks
sarahchen6 a9f1937
Update image
sarahchen6 db65ba5
Merge branch 'master' into sarahchen6/migrate-benchmarks
sarahchen6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import json | ||
| import os | ||
| import sys | ||
| from io import StringIO | ||
|
|
||
| import numpy as np | ||
|
|
||
| from python_utils import compute_confidence_interval, import_benchmark_values, round_value | ||
|
|
||
| NO_AGENT_VARIANT = os.getenv("NO_AGENT_VARIANT") | ||
| CI_INTERVAL = 0.99 | ||
| UOM = "µs" | ||
| CANDIDATE = os.getenv("CANDIDATE_VERSION") | ||
| BASELINE = os.getenv("BASELINE_VERSION") | ||
|
|
||
| input_folder = sys.argv[1] | ||
|
|
||
|
|
||
| def _parse_benchmarks(folder: str, build: str) -> list[float]: | ||
| with open(f"{folder}/benchmark-{build}.json", "r", encoding="utf-8") as reader: | ||
| benchmark_json = json.loads(reader.read()) | ||
| return import_benchmark_values(list(benchmark_json["benchmarks"])[0], "execution_time", UOM) | ||
|
|
||
|
|
||
| def _sort_variants(item: str) -> str: | ||
| if item == NO_AGENT_VARIANT: | ||
| return "" | ||
| return item | ||
|
|
||
|
|
||
| def _build_application_results(folder: str) -> str: | ||
| application = os.path.basename(folder) | ||
| chart = StringIO() | ||
| tables = { | ||
| "baseline": StringIO(), | ||
| "candidate": StringIO(), | ||
| } | ||
| values = { | ||
| "baseline": dict(), | ||
| "candidate": dict(), | ||
| } | ||
| for variant_folder in [f.path for f in os.scandir(application_folder) if f.is_dir()]: | ||
| variant = os.path.basename(variant_folder) | ||
| values["candidate"][variant] = _parse_benchmarks(variant_folder, "candidate") | ||
| values["baseline"][variant] = _parse_benchmarks(variant_folder, "baseline") | ||
| no_agent_means = { | ||
| "baseline": float(np.mean(values["baseline"][NO_AGENT_VARIANT])), | ||
| "candidate": float(np.mean(values["candidate"][NO_AGENT_VARIANT])), | ||
| } | ||
| variants = sorted(values["candidate"].keys(), key=_sort_variants) | ||
| chart.write( | ||
| f""" | ||
| ```mermaid | ||
| gantt | ||
| title {application} - execution time [CI {CI_INTERVAL}] : candidate={CANDIDATE}, baseline={BASELINE} | ||
| dateFormat X | ||
| axisFormat %s | ||
| """ | ||
| ) | ||
|
|
||
| for build in ("baseline", "candidate"): | ||
| table = tables[build] | ||
| table.write(f"\n|Variant|Execution Time [CI {CI_INTERVAL}]|Δ {NO_AGENT_VARIANT}|\n") | ||
| table.write("|---|---|---|\n") | ||
| build_values = values[build] | ||
| no_agent_mean = no_agent_means[build] | ||
| chart.write(f"section {build}\n") | ||
| for variant in variants: | ||
| variant_values = build_values[variant] | ||
| mean = float(np.mean(variant_values)) | ||
| lower, upper = compute_confidence_interval(variant_values, CI_INTERVAL) | ||
| overhead = mean - no_agent_mean | ||
| overhead_pct = overhead * 100 / no_agent_mean | ||
| chart.write(f"{variant} ({round_value(mean, UOM)}) : {round(lower)}, {round(upper)}\n") | ||
| chart.write(f". : milestone, {round(mean)},\n") | ||
| table.write( | ||
| f"|{variant}|{round_value(mean, UOM)} [{round_value(lower, UOM)}, {round_value(upper, UOM)}]" | ||
| f"|{'-' if variant == NO_AGENT_VARIANT else f'{round_value(overhead, UOM)} ({round(overhead_pct, 1)}%)'}|\n" | ||
| ) | ||
|
|
||
| chart.write("```\n") | ||
|
|
||
| result = StringIO() | ||
| result.write(f"\n\n<details><summary>Execution time for {application}</summary>\n") | ||
| result.write(chart.getvalue()) | ||
| for build, table in tables.items(): | ||
| result.write(f"\n* **{build}** results\n") | ||
| result.write(table.getvalue()) | ||
| result.write("\n</details>\n") | ||
| return result.getvalue() | ||
|
|
||
|
|
||
| for application_folder in [f.path for f in os.scandir(input_folder) if f.is_dir()]: | ||
| print(_build_application_results(application_folder)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.