Skip to content

Commit

Permalink
Post benchmark results to the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Nov 28, 2024
1 parent d107fe3 commit 7aa9553
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: "Benchmarks"

permissions:
contents: write
pull-requests: write

on:
pull_request:

Expand All @@ -24,4 +28,21 @@ jobs:
cd benchmarks
./runAll.sh
# This in conjunction with create-or-update-comment allows us to only
# comment once and update it after
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Benchmark results

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: benchmark_results.md
edit-mode: replace

29 changes: 25 additions & 4 deletions benchmarks/runAll.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/env bash
set -e

LFC=lfc
Expand All @@ -16,7 +17,27 @@ ping_pong_uc_result=$(bin/PingPongUc | grep -E "Time: *.")
latency_c_result=$(bin/ReactionLatencyC | grep -E " latency: *.")
latency_uc_result=$(bin/ReactionLatencyUc | grep -E " latency: *.")

echo "PingPongUc:\n $ping_pong_uc_result"
echo "PingPongC:\n $ping_pong_c_result"
echo "ReactionLatencyUc:\n $latency_uc_result"
echo "ReactionLatencyC:\n $latency_c_result"

# Create or clear the output file
output_file="benchmark_results.md"
: > "$output_file"

# Print and dump the results into the file
echo "## Benchmark results" >> "$output_file"

benchmarks=("PingPongUc" "PingPongC" "ReactionLatencyUc" "ReactionLatencyC")
results=("$ping_pong_uc_result" "$ping_pong_c_result" "$latency_uc_result" "$latency_c_result")

for i in "${!benchmarks[@]}"; do
echo "${benchmarks[$i]}:" >> "$output_file"
echo "${results[$i]}" >> "$output_file"
done

echo "## Benchmark memory usage:" >> "$output_file"
for benchmark in PingPongUc PingPongC ReactionLatencyUc ReactionLatencyC;
do
echo "$benchmark:" >> "$output_file"
echo "$(size -d bin/$benchmark)" >> "$output_file"
done

cat "$output_file"
6 changes: 3 additions & 3 deletions benchmarks/src/ReactionLatencyC.lf
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ preamble {=

reaction(shutdown) {=
qsort(self->latencies, self->num_iterations, sizeof(interval_t), comp);
printf("Best latency: %ld nsec\n", self->latencies[0]);
printf("Median latency: %ld nsec\n", self->latencies[self->num_iterations / 2]);
printf("Worst latency: %ld nsec\n", self->latencies[self->num_iterations - 1]);
printf("Best latency:\t %ld nsec\n", self->latencies[0]);
printf("Median latency:\t %ld nsec\n", self->latencies[self->num_iterations / 2]);
printf("Worst latency:\t %ld nsec\n", self->latencies[self->num_iterations - 1]);
=}
}

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/ReactionLatencyUc.lf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ preamble {=

reaction(shutdown) {=
qsort(self->latencies, self->num_iterations, sizeof(interval_t), comp);
printf("Best latency: %ld nsec\n", self->latencies[0]);
printf("Median latency: %ld nsec\n", self->latencies[self->num_iterations / 2]);
printf("Worst latency: %ld nsec\n", self->latencies[self->num_iterations - 1]);
printf("Best latency:\t %ld nsec\n", self->latencies[0]);
printf("Median latency:\t %ld nsec\n", self->latencies[self->num_iterations / 2]);
printf("Worst latency:\t %ld nsec\n", self->latencies[self->num_iterations - 1]);
=}
}

Expand Down

0 comments on commit 7aa9553

Please sign in to comment.