Skip to content
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

Add github benchmark action #78

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
bench:
runs-on: self-hosted-rpi4
permissions:
contents: write
if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v4
Expand All @@ -34,4 +36,13 @@ jobs:
- name: Run benchmark
shell: nix develop .#ci -c bash -e {0}
run: |
tests bench -c PMU --cflags -mcpu=cortex-a72 -v
tests bench -c PMU --cflags -mcpu=cortex-a72 -v --output output.json
- name: Store benchmark result
if: github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Arm Cortex-A72 (Raspberry Pi 4) benchmarks
tool: 'customSmallerIsBetter'
output-file-path: output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
36 changes: 35 additions & 1 deletion scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ def kat(force_qemu, verbose, cflags, arch_flags):
default="NO",
help="Method for counting clock cycles. PMU requires (user-space) access to the Arm Performance Monitor Unit (PMU). PERF requires a kernel with perf support.",
)
def bench(force_qemu, verbose, cycles, cflags, arch_flags):
@click.option(
"-o",
"--output",
nargs=1,
help="Path to output file in json format",
)
def bench(force_qemu, verbose, cycles, cflags, arch_flags, output):
config_logger(verbose)

results = test_schemes(
Expand All @@ -360,6 +366,34 @@ def bench(force_qemu, verbose, cycles, cflags, arch_flags):
[f"CYCLES={cycles}"],
)

if output:
import json

with open(output, "w") as f:
v = []
for scheme in results:
schemeStr = str(scheme)
r = results[scheme]

# The first 3 lines of the output are expected to be
# keypair cycles=X
# encaps cycles=X
# decaps cycles=X

d = {
k: int(v)
for k, v in (l.decode().split("=") for l in r.splitlines()[:3])
mkannwischer marked this conversation as resolved.
Show resolved Hide resolved
}
for primitive in ["keypair", "encaps", "decaps"]:
v.append(
{
"name": f"{schemeStr} {primitive}",
"unit": "cycles",
"value": d[f"{primitive} cycles"],
hanno-becker marked this conversation as resolved.
Show resolved Hide resolved
}
)
f.write(json.dumps(v))


@click.group(invoke_without_command=True)
def cli():
Expand Down
Loading