From 3ec1c1695565d613669cb457430a7b03ef534b61 Mon Sep 17 00:00:00 2001 From: raphaelDkhn <113879115+raphaelDkhn@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:28:19 +0000 Subject: [PATCH] Update benchmark.yaml --- .github/workflows/benchmark.yaml | 38 +++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 9c7355e..7742a7e 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -24,29 +24,21 @@ jobs: - name: Run benchmark run: | - # Run benchmarks and capture output - cargo bench --bench tensor_ops > raw_output.txt - - # Process the output to match cargo benchmark format - cat raw_output.txt | while IFS= read -r line; do - if [[ $line =~ time:.*\[(.*?) .*\] ]]; then - name=$(echo "$line" | grep -oP '^[^time]*' | tr -d ' ') - time="${BASH_REMATCH[1]}" - # Convert to ns if needed - if [[ $line =~ µs ]]; then - time=$(echo "$time * 1000" | bc) - elif [[ $line =~ ms ]]; then - time=$(echo "$time * 1000000" | bc) - fi - echo "test $name ... bench: $time ns/iter (+/- 0)" - fi - done > output.txt - - - name: Download previous benchmark data - uses: actions/cache@v4 - with: - path: ./cache - key: ${{ runner.os }}-benchmark + # Run benchmarks and format output + cargo bench --bench tensor_ops 2>&1 | awk ' + /time:/ { + name=$1 + split($4, times, " ") + gsub(/[\[\],]/, "", times[1]) + + # Convert to nanoseconds + time=times[1] + if ($5 ~ /µs/) time=time*1000 + if ($5 ~ /ms/) time=time*1000000 + + printf "test %s ... bench: %d ns/iter (+/- 0)\n", name, time + } + ' > output.txt - name: Store benchmark result uses: benchmark-action/github-action-benchmark@v1