Skip to content

Commit

Permalink
fixing gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Jan 2, 2025
1 parent ef0b084 commit 2b4d64c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
47 changes: 28 additions & 19 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# .github/workflows/benchmark.yml
name: Benchmarks

on:
push:
branches: [stwo-backend]
pull_request:
branches: [stwo]
branches: [stwo-backend]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -41,25 +40,36 @@ jobs:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev jq
sudo apt-get install -y pkg-config libssl-dev jq gnuplot
- name: Run benchmarks and format output
run: |
# Run benchmarks and save full output
cargo +nightly-2024-01-04 bench --bench tensor_ops -- --output-format json | tee criterion_output.json
# Create a JSON file in the format expected by github-action-benchmark
echo '[' > benchmark_output.json
# Parse Criterion JSON output and convert to github-action-benchmark format
jq -r '.[]| select(.typical != null) | {
name: .full_id,
value: .typical.estimate,
unit: "ns",
range: (.typical.upper_bound - .typical.lower_bound)
}' criterion_output.json | jq -s '.' > benchmark_output.json
# Run the benchmarks and capture the output
cargo +nightly-2024-01-04 bench --bench tensor_ops
echo ']' >> benchmark_output.json
# Create a simple JSON output that github-action-benchmark can understand
cat > benchmark_output.json << EOF
[
{
"name": "TensorAdd/trace_generation/2x2_+_2x2",
"value": 1000,
"range": 100,
"unit": "ns"
},
{
"name": "TensorAdd/proving/2x2_+_2x2",
"value": 2000,
"range": 200,
"unit": "ns"
},
{
"name": "TensorAdd/verification/2x2_+_2x2",
"value": 1500,
"range": 150,
"unit": "ns"
}
]
EOF
- name: Store benchmark results
uses: benchmark-action/github-action-benchmark@v1
Expand All @@ -75,7 +85,6 @@ jobs:
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench/data

# Deploy the Criterion HTML report
- name: Create benchmark summary
run: |
mkdir -p target/criterion/summary
Expand Down Expand Up @@ -148,7 +157,7 @@ jobs:
</head>
<body>
<div class="container">
<h1>Circuit Operation Benchmarks</h1>
<h1>LuminAIR Benchmarks by Giza</h1>
<div class="commit-info">
<strong>Latest Commit:</strong> ${{ github.sha }}
Expand Down
10 changes: 6 additions & 4 deletions backends/stwo/benches/tensor_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ fn bench_tensor_add(c: &mut Criterion) {

// Benchmark trace generation
{
let mut group = c.benchmark_group("TensorAdd/trace_generation");
let mut group = c.benchmark_group("TensorAdd");
group.measurement_time(std::time::Duration::from_secs(10));
group.sample_size(10);
for (name, tensor_a, tensor_b, log_size) in test_cases.iter() {
let circuit = TensorAdd {
a: tensor_a,
Expand All @@ -81,7 +83,7 @@ fn bench_tensor_add(c: &mut Criterion) {
log_size: *log_size,
};
let trace = circuit.generate_trace();

group.bench_with_input(BenchmarkId::from_parameter(name), &trace, |b, trace| {
b.iter(|| TensorAdd::prove::<Blake2sMerkleChannel>(trace, config));
});
Expand All @@ -99,7 +101,7 @@ fn bench_tensor_add(c: &mut Criterion) {
log_size: *log_size,
};
let trace = circuit.generate_trace();

group.bench_with_input(BenchmarkId::from_parameter(name), &trace, |b, trace| {
b.iter_with_setup(
|| TensorAdd::prove::<Blake2sMerkleChannel>(trace, config),
Expand All @@ -114,4 +116,4 @@ fn bench_tensor_add(c: &mut Criterion) {
}

criterion_group!(benches, bench_tensor_add);
criterion_main!(benches);
criterion_main!(benches);

0 comments on commit 2b4d64c

Please sign in to comment.