diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..a1b0df28 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,73 @@ +name: Benchmark + +on: + pull_request: + types: [labeled] + workflow_dispatch: + +# Make sure that we only benchmark the last version per branch, max one at the time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + +jobs: + build: + if: ${{ github.event.label.name == 'benchmark' }} + runs-on: macos-latest + defaults: + run: + working-directory: ./Benchmarks + strategy: + matrix: + xcode: ["15.4"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: brew install jemalloc + + - name: Run benchmark + run: | + swift package --allow-writing-to-package-directory benchmark --no-progress --format jmh + ls -la + + - name: Upload artifacts + uses: actions/upload-artifact@v4.4.3 + with: + name: benchmarks-${{ matrix.xcode }}-${{ github.run_id }} + path: | + Current_run.jmh.json + Benchmarks/Current_run.jmh.json + *.jmh.json + if-no-files-found: warn + include-hidden-files: true + + # Run `github-action-benchmark` action + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1.20.3 + with: + # What benchmark tool the output.txt came from + tool: "jmh" + # Where the output from the benchmark tool is stored + output-file-path: Benchmarks/Current_run.jmh.json + # Where the previous data file is stored + # external-data-json-path: ./cache/benchmark-data.json + # Workflow will fail when an alert happens + # fail-on-alert: true + fail-on-alert: true + # GitHub API token to make a commit comment + github-token: ${{ secrets.GITHUB_TOKEN }} + # Enable alert commit comment + # comment-on-alert: true + # Enable Job Summary for PRs + summary-always: true + # Mention @rhysd in the commit comment + # alert-comment-cc-users: "@rhysd" + save-data-file: false + skip-fetch-gh-pages: true diff --git a/Benchmarks/Package.resolved b/Benchmarks/Package.resolved new file mode 100644 index 00000000..3f0277ea --- /dev/null +++ b/Benchmarks/Package.resolved @@ -0,0 +1,77 @@ +{ + "pins" : [ + { + "identity" : "hdrhistogram-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/HdrHistogram/hdrhistogram-swift", + "state" : { + "revision" : "a69fa24d7b70421870cafa86340ece900489e17e", + "version" : "0.1.2" + } + }, + { + "identity" : "package-benchmark", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-benchmark", + "state" : { + "revision" : "f9dcf0b540c4973ab1cef7893fb46e34a4e74099", + "version" : "1.27.2" + } + }, + { + "identity" : "package-jemalloc", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-jemalloc", + "state" : { + "revision" : "e8a5db026963f5bfeac842d9d3f2cc8cde323b49", + "version" : "1.0.0" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "41982a3656a71c768319979febd796c6fd111d5c", + "version" : "1.5.0" + } + }, + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics", + "state" : { + "revision" : "cd142fd2f64be2100422d658e7411e39489da985", + "version" : "1.2.0" + } + }, + { + "identity" : "swift-numerics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-numerics", + "state" : { + "revision" : "0a5bc04095a675662cf24757cc0640aa2204253b", + "version" : "1.0.2" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system", + "state" : { + "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", + "version" : "1.3.2" + } + }, + { + "identity" : "texttable", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/TextTable", + "state" : { + "revision" : "a27a07300cf4ae322e0079ca0a475c5583dd575f", + "version" : "0.0.2" + } + } + ], + "version" : 2 +}