Skip to content

Commit

Permalink
Applied requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zeme-wana committed Mar 20, 2023
1 parent ab91a7d commit 47006c6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
32 changes: 6 additions & 26 deletions .github/workflows/longitudinal-benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Longitudinal Benchmarking
# Longitudinal Benchmarks
#
# This workflow will run the benchmarks defined in the environment variable BENCHMARKS.
# It will collect and aggreate the benchmark output, format it and feed it to github-action-benchmark.
#
# The benchmark charts are live at https://input-output-hk.github.io/plutus/dev/bench
# The benchmark data is available at https://input-output-hk.github.io/plutus/dev/bench/data.js

name: Longitudinal Benchmarking
name: Longitudinal Benchmarks

on:
push:
Expand All @@ -20,9 +20,9 @@ permissions:
contents: write

jobs:
new-benchmark:
longitudinal-benchmarks:
name: Performance regression check
runs-on: ubuntu-latest
runs-on: [self-hosted, plutus-benchmark]
steps:
- uses: actions/[email protected]

Expand All @@ -33,33 +33,13 @@ jobs:
for bench in $BENCHMARKS; do
2>&1 cabal run "$bench" | tee "$bench-output.txt"
done
python ./scripts/format-benchmark-output.py
read -r -d '' PYTHON_SCRIPT <<- END_SCRIPT
import json
result = []
for benchmark in "$BENCHMARKS".split():
with open(f"{benchmark}-output.txt", "r") as file:
name = ""
for line in file.readlines():
if line.startswith("benchmarking"):
name = line.split()[1]
elif line.startswith("mean"):
parts = line.split()
mean = parts[1]
unit = parts[2]
result.append({
"name": f"{benchmark}-{name}",
"unit": unit,
"value": float(mean)
})
with open("output.json", "w") as file:
json.dump(result, file)
END_SCRIPT
- name: Store benchmark result
uses: benchmark-action/[email protected]
with:
name: My Project Go Benchmark
name: Plutus Benchmarks
tool: 'customSmallerIsBetter'
output-file-path: output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
23 changes: 23 additions & 0 deletions scripts/format-benchmark-output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import os

result = []

for benchmark in os.getenv("BENCHMARKS").split():
with open(f"{benchmark}-output.txt", "r") as file:
name = ""
for line in file.readlines():
if line.startswith("benchmarking"):
name = line.split()[1]
elif line.startswith("mean"):
parts = line.split()
mean = parts[1]
unit = parts[2]
result.append({
"name": f"{benchmark}-{name}",
"unit": unit,
"value": float(mean)
})

with open("output.json", "w") as file:
json.dump(result, file)

0 comments on commit 47006c6

Please sign in to comment.