DOCS: Update remaining TritNet path references in README and reports #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Performance Benchmarks | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: # Allow manual triggering | |
| inputs: | |
| compare_baseline: | |
| description: 'Compare against baseline' | |
| required: false | |
| default: 'true' | |
| benchmark_mode: | |
| description: 'Benchmark mode (quick/full)' | |
| required: false | |
| default: 'quick' | |
| type: choice | |
| options: | |
| - quick | |
| - full | |
| env: | |
| # Benchmark configuration | |
| PYTHON_VERSION: '3.11' | |
| BENCHMARK_MODE: ${{ github.event.inputs.benchmark_mode || 'quick' }} | |
| BENCHMARK_TIMEOUT_MINUTES: '30' | |
| BENCHMARK_RETENTION_DAYS: '30' | |
| # Dependency versions | |
| PYBIND11_VERSION: 'latest' | |
| NUMPY_VERSION: 'latest' | |
| # Build configuration | |
| MSVC_ARCH: 'x64' | |
| jobs: | |
| benchmark: | |
| name: Run Benchmarks | |
| runs-on: ubuntu-latest | |
| timeout-minutes: ${{ fromJSON(vars.BENCHMARK_TIMEOUT_MINUTES || '30') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for comparison | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install GCC compiler | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential g++ | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools pybind11 numpy | |
| - name: Build module | |
| run: python build.py | |
| - name: Verify module was built | |
| run: | | |
| echo "Checking for built module..." | |
| ls -la *.so *.pyd 2>/dev/null || true | |
| echo "Testing module import..." | |
| python -c "import sys; print('Python path:', sys.path); import ternary_simd_engine as tc; print('✓ Module loaded successfully'); print('Available functions:', dir(tc))" | |
| - name: Run benchmark | |
| run: | | |
| python benchmarks/bench_phase0.py ${{ env.BENCHMARK_MODE == 'quick' && '--quick' || '' }} --output=benchmarks/results/current --no-unicode | |
| continue-on-error: true | |
| env: | |
| BENCHMARK_ITERATIONS: ${{ secrets.BENCHMARK_ITERATIONS || '1000' }} | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmarks/results/ | |
| retention-days: ${{ fromJSON(vars.BENCHMARK_RETENTION_DAYS || env.BENCHMARK_RETENTION_DAYS) }} | |
| - name: Download baseline from main branch | |
| if: github.event_name == 'pull_request' | |
| continue-on-error: true | |
| uses: dawidd6/action-download-artifact@v2 | |
| with: | |
| workflow: benchmarks.yml | |
| branch: main | |
| name: benchmark-results | |
| path: benchmarks/results/baseline/ | |
| if_no_artifact_found: warn | |
| - name: Compare with baseline | |
| if: github.event_name == 'pull_request' | |
| continue-on-error: true | |
| run: | | |
| # Check if baseline was downloaded | |
| if ls benchmarks/results/baseline/bench_results_*.json 1> /dev/null 2>&1; then | |
| echo "Baseline found, running comparison..." | |
| BASELINE_FILE=$(ls benchmarks/results/baseline/bench_results_*.json | head -n 1) | |
| CURRENT_FILE=$(ls benchmarks/results/current/bench_results_*.json | head -n 1) | |
| python benchmarks/bench_compare.py \ | |
| "$BASELINE_FILE" \ | |
| "$CURRENT_FILE" \ | |
| --threshold=5.0 | |
| else | |
| echo "⚠️ No baseline found - this is the first benchmark run or baseline artifact not available" | |
| echo "Future PR comparisons will use this run as baseline" | |
| fi | |
| - name: Performance summary | |
| if: always() | |
| run: | | |
| echo "## Benchmark Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f "benchmarks/results/current/bench_results_"*.json ]; then | |
| echo "Benchmark completed successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "Results uploaded as artifact" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ Benchmark may have failed" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| benchmark-windows: | |
| name: Benchmark on Windows | |
| runs-on: windows-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Set up MSVC compiler | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools pybind11 numpy | |
| - name: Build module | |
| run: python build.py | |
| - name: Verify module was built | |
| run: | | |
| echo "Checking for built module..." | |
| if (Test-Path "*.pyd") { | |
| Get-ChildItem *.pyd | ForEach-Object { Write-Host "Found: $($_.Name)" } | |
| } else { | |
| Write-Host "[ERROR] No .pyd file found!" | |
| exit 1 | |
| } | |
| echo "Testing module import..." | |
| python -c "import ternary_simd_engine as tc; print('Module loaded OK'); print('Functions:', dir(tc))" | |
| shell: pwsh | |
| - name: Run quick benchmark | |
| run: | | |
| python benchmarks/bench_phase0.py --quick --output=benchmarks/results/windows --no-unicode | |
| - name: Upload Windows benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results-windows | |
| path: benchmarks/results/ | |
| pgo-benchmark: | |
| name: PGO Build Benchmark | |
| runs-on: windows-latest | |
| timeout-minutes: 45 | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Set up MSVC compiler | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools pybind11 numpy | |
| - name: Build with PGO | |
| run: python build_pgo.py full | |
| continue-on-error: true # PGO may fail on CI runners | |
| - name: Verify PGO module was built | |
| if: success() | |
| run: | | |
| Write-Host "Checking for PGO-optimized module in project root..." | |
| if (Test-Path "ternary_simd_engine*.pyd") { | |
| Write-Host "[OK] PGO module built successfully" | |
| Get-ChildItem ternary_simd_engine*.pyd | ForEach-Object { | |
| Write-Host " Found: $($_.Name) ($([math]::Round($_.Length/1KB, 2)) KB)" | |
| } | |
| Write-Host "`nTesting module import..." | |
| python -c "import ternary_simd_engine as tc; print('[OK] PGO module import successful')" | |
| } else { | |
| Write-Host "[ERROR] No .pyd file found in project root after PGO build!" | |
| Write-Host "`nChecking build artifacts:" | |
| if (Test-Path "build/artifacts/pgo") { | |
| Get-ChildItem -Path build/artifacts/pgo -Recurse -Filter "*.pyd" -ErrorAction SilentlyContinue | ForEach-Object { | |
| Write-Host " Found in artifacts: $($_.FullName)" | |
| } | |
| } | |
| exit 1 | |
| } | |
| shell: pwsh | |
| - name: Run PGO benchmark | |
| if: success() | |
| run: | | |
| python benchmarks/bench_phase0.py --quick --output=benchmarks/results/pgo --no-unicode | |
| - name: Upload PGO results | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results-pgo | |
| path: benchmarks/results/ |