Skip to content

Commit

Permalink
add github benchmark action
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias J. Kannwischer <[email protected]>
  • Loading branch information
mkannwischer committed Jun 26, 2024
1 parent ac842f8 commit 33ccd2a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
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
30 changes: 29 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(
"-output",
"--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,28 @@ 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]
d = {
k: int(v)
for k, v in (l.decode().split("=") for l in r.splitlines()[:3])
}
for primitive in ["keypair", "encaps", "decaps"]:
v.append(
{
"name": f"{schemeStr} {primitive}",
"unit": "cycles",
"value": d[f"{primitive} cycles"],
}
)
f.write(json.dumps(v))


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

0 comments on commit 33ccd2a

Please sign in to comment.