|
| 1 | +name: Weekly Performance |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + name: |
| 7 | + description: "Manual trigger" |
| 8 | + schedule: |
| 9 | + - cron: '12 13 * * 7' |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + performance: |
| 16 | + name: Performance |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v5 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + ref: ${{ github.ref }} |
| 25 | + |
| 26 | + - name: Install CMake and prerequisites |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + sudo apt-get update |
| 30 | + sudo apt-get install -y build-essential curl python3-pip valgrind |
| 31 | + python3 -m pip install --upgrade pip |
| 32 | + python3 -m pip install msparser matplotlib |
| 33 | +
|
| 34 | + # CMake 3.31.8 |
| 35 | + CMAKE_VER=3.31.8 |
| 36 | + curl -L "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-x86_64.tar.gz" -o cmake-${CMAKE_VER}.tgz |
| 37 | + sudo tar -C /opt -xzf cmake-${CMAKE_VER}.tgz |
| 38 | + echo "/opt/cmake-${CMAKE_VER}-linux-x86_64/bin" >> "$GITHUB_PATH" |
| 39 | +
|
| 40 | + - name: Run tests |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + ./test/memory/memory_test.sh |
| 44 | +
|
| 45 | + - name: Save results into memory |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + set -euxo pipefail |
| 49 | + mkdir -p ci/metrics/complete_profile/runs |
| 50 | +
|
| 51 | + stamp="$(date -u +%Y%m%dT%H%M%SZ)_${GITHUB_RUN_NUMBER}_${GITHUB_SHA::8}" |
| 52 | + cp build/complete_profile.csv "ci/metrics/complete_profile/runs/${stamp}.csv" |
| 53 | +
|
| 54 | + git config user.name "github-actions" |
| 55 | + git config user.email "github-actions@github.com" |
| 56 | +
|
| 57 | + BR="memory/performance" # Use this branch to store performance results |
| 58 | + git fetch origin "${BR}" || true |
| 59 | + git checkout -B "${BR}" |
| 60 | +
|
| 61 | + git add ci/metrics/complete_profile/runs/ |
| 62 | + git diff --cached --quiet || git commit -m "metrics: complete_profile run ${GITHUB_RUN_NUMBER} (${GITHUB_SHA::8})" |
| 63 | + git push -f origin "${BR}" |
| 64 | +
|
| 65 | + - name: Generate plots |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + set -euxo pipefail |
| 69 | + python3 - <<'PY' |
| 70 | + import glob, os, csv, re |
| 71 | + from pathlib import Path |
| 72 | + import matplotlib.pyplot as plt |
| 73 | +
|
| 74 | + runs_dir = Path("ci/metrics/complete_profile/runs") |
| 75 | + out_png = Path("build/complete_profile_last30.png") |
| 76 | + out_png.parent.mkdir(parents=True, exist_ok=True) |
| 77 | +
|
| 78 | + files = sorted(runs_dir.glob("*.csv"))[-30:] # last 30 by filename (timestamp prefix) |
| 79 | + if not files: |
| 80 | + raise SystemExit("No historical CSVs found in ci/metrics/complete_profile/runs") |
| 81 | +
|
| 82 | + y_vals = [] |
| 83 | + for f in files: |
| 84 | + with f.open(newline="") as fh: |
| 85 | + reader = csv.DictReader(fh) |
| 86 | + row = next(reader, None) |
| 87 | + if row is None: |
| 88 | + continue |
| 89 | + # CSV values are quoted strings; convert to int safely |
| 90 | + val = row.get("text") |
| 91 | + if val is None: |
| 92 | + continue |
| 93 | + y_vals.append(int(val)) |
| 94 | +
|
| 95 | + if not y_vals: |
| 96 | + raise SystemExit("No numeric 'text' values found to plot") |
| 97 | +
|
| 98 | + plt.figure() |
| 99 | + plt.plot(range(1, len(y_vals)+1), y_vals) # line plot |
| 100 | + plt.title("Complete Profile") |
| 101 | + plt.xlabel("Run (old → new)") |
| 102 | + plt.ylabel("Bytes") |
| 103 | + plt.xticks([]) # keep clean |
| 104 | + plt.tight_layout() |
| 105 | + plt.savefig(out_png) |
| 106 | + print(f"Wrote {out_png}") |
| 107 | + PY |
| 108 | +
|
| 109 | + - name: Upload artifacts |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: performance-results |
| 113 | + path: | |
| 114 | + build/complete_profile.csv |
| 115 | + build/complete_profile_last30.png |
| 116 | + if-no-files-found: warn |
| 117 | + |
| 118 | + - name: Add summary |
| 119 | + if: always() |
| 120 | + shell: bash |
| 121 | + run: | |
| 122 | + echo "## Complete Profile (last 30 runs)" >> "$GITHUB_STEP_SUMMARY" |
| 123 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 124 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments