rust-cc 0.6.2

A cycle collector for Rust programs
Documentation
name: Benchmark

on:
  pull_request:
    types: [labeled]

env:
  CARGO_TERM_COLOR: always
  IAI_CALLGRIND_COLOR: never
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
  bench:
    if: contains(github.event.pull_request.labels.*.name, 'run benchmarks')
    permissions:
      pull-requests: write
    env:
      WORKSPACE: ${{ github.workspace }}
      URL: ${{ github.event.pull_request.comments_url }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.base.ref }}
      - uses: dtolnay/rust-toolchain@stable
      - uses: taiki-e/install-action@valgrind
      - uses: taiki-e/install-action@cargo-binstall
      - name: Install iai-callgrind-runner
        run: |
          version=$(cargo metadata --format-version=1 |\
            jq '.packages[] | select(.name == "iai-callgrind").version' |\
            tr -d '"'
          )
          cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version "${version}"
      - name: Bench base branch
        run: |
          cargo update
          cargo bench -q --bench bench > "${WORKSPACE}"/____old_results.txt
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          clean: false
      - name: Bench head branch
        run: |
          cargo update
          cargo bench -q --bench bench > "${WORKSPACE}"/____results.txt
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.base.ref }}
          clean: false
      - name: Bench base branch no finalization
        run: |
          cargo clean
          cargo update
          cargo bench --no-default-features -F std,derive,auto-collect -q --bench bench > "${WORKSPACE}"/____old_results_no_finalization.txt
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          clean: false
      - name: Bench head branch no finalization
        run: |
          cargo update
          cargo bench --no-default-features -F std,derive,auto-collect -q --bench bench > "${WORKSPACE}"/____results_no_finalization.txt
      - name: Write comment
        run: |
          {
            echo '<strong>Benchmark results:</strong>'
            echo ''
            echo '```txt'
            cat "${WORKSPACE}"/____results.txt
            echo '```'
            echo ''
            echo '<details><summary><strong>Old results:</strong></summary><p>'
            echo ''
            echo '```txt'
            cat "${WORKSPACE}"/____old_results.txt
            echo '```'
            echo '</p></details>'
            echo ''
            echo '---'
            echo ''
            echo '<details><summary><strong>Results without finalization:</strong></summary><p>'
            echo ''
            echo '```txt'
            cat "${WORKSPACE}"/____results_no_finalization.txt
            echo '```'
            echo ''
            echo '<details><summary><strong>Old results without finalization:</strong></summary><p>'
            echo ''
            echo '```txt'
            cat "${WORKSPACE}"/____old_results_no_finalization.txt
            echo '```'
            echo '</p></details></p></details>'
          } > "${WORKSPACE}"/__result.txt
      - uses: thollander/actions-comment-pull-request@v2.3.1
        with:
          filePath: '__result.txt'
          mode: recreate
      - name: Remove label
        uses: actions-ecosystem/action-remove-labels@v1.3.0
        with:
          labels: "run benchmarks"