diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..fbe999ed --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,125 @@ +--- +name: Benchmarking + +on: + workflow_dispatch: + +jobs: + benchmark-baseline: + name: "Benchmark Baseline" + + runs-on: "${{ matrix.operating-system }}" + + strategy: + fail-fast: false + + matrix: + operating-system: + - "ubuntu-22.04" + + php-version: + - "8.1" + + steps: + - # https://github.com/actions/checkout + name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: "9.1" + repository: "overtrue/phplint" + + - # https://github.com/shivammathur/setup-php + name: Setup PHP runtime + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + coverage: "none" + + - # https://github.com/ramsey/composer-install + name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + composer-options: "--prefer-dist" + + - # https://github.com/phpbench/phpbench + name: Install PHPBench + run: | + curl -Ls https://github.com/phpbench/phpbench/releases/download/1.2.15/phpbench.phar -o /usr/local/bin/phpbench + chmod +x /usr/local/bin/phpbench + + - # https://github.com/phpbench/phpbench + name: Benchmark baseline + run: | + phpbench run tests/Benchmark --tag=${{ matrix.php-version }} + + - # https://github.com/actions/upload-artifact + name: Upload PHPBench baseline + uses: actions/upload-artifact@v3 + with: + name: "PHPBench-Baseline" + path: ".phpbench/" + + benchmark-report: + needs: benchmark-baseline + + name: "Benchmark Report" + + runs-on: "${{ matrix.operating-system }}" + + strategy: + fail-fast: false + + matrix: + operating-system: + - "ubuntu-22.04" + + php-version: + - "8.3" + + steps: + - # https://github.com/actions/checkout + name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: "9.1" + repository: "overtrue/phplint" + + - # https://github.com/shivammathur/setup-php + name: Setup PHP runtime + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + coverage: "none" + + - # https://github.com/ramsey/composer-install + name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + composer-options: "--prefer-dist" + + - # https://github.com/phpbench/phpbench + name: Install PHPBench + run: | + curl -Ls https://github.com/phpbench/phpbench/releases/download/1.2.15/phpbench.phar -o /usr/local/bin/phpbench + chmod +x /usr/local/bin/phpbench + + - # https://github.com/actions/download-artifact + name: Retrieve PHPBench baseline results + uses: actions/download-artifact@v3 + with: + name: "PHPBench-Baseline" + path: ".phpbench/" + + - # https://github.com/phpbench/phpbench + name: Benchmark Reports + run: | + phpbench run tests/Benchmark --tag=${{ matrix.php-version }} --ref="8.1" --report=aggregate --report overview --output=html + + - # https://github.com/actions/upload-artifact + name: Upload PHPBench report + uses: actions/upload-artifact@v3 + with: + name: "PHPBench-Report" + path: ".phpbench/html/index.html"