Skip to content
Latchkey

Benchmark workflow (httpie/httpie)

The Benchmark workflow from httpie/httpie, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: httpie/httpie.github/workflows/benchmark.ymlLicense BSD-3-ClauseView source

What it does

This is the Benchmark workflow from the httpie/httpie repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Benchmark

on:
  pull_request:
    types: [ labeled ]

permissions:
  issues: write
  pull-requests: write

jobs:
  test:
    if: github.event.label.name == 'benchmark'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: "3.9"

      - id: benchmarks
        name: Run Benchmarks
        run: |
          python -m pip install pyperf>=2.3.0
          python extras/profiling/run.py --fresh --complex  --min-speed=6 --file output.txt
          body=$(cat output.txt)
          body="${body//'%'/'%25'}"
          body="${body//$'\n'/'%0A'}"
          body="${body//$'\r'/'%0D'}"
          echo "::set-output name=body::$body"

      - name: Find Comment
        uses: peter-evans/find-comment@v2
        id: fc
        with:
          issue-number: ${{ github.event.pull_request.number }}
          comment-author: 'github-actions[bot]'
          body-includes: '# Benchmarks'

      - name: Create or update comment
        uses: peter-evans/create-or-update-comment@v2
        with:
          comment-id: ${{ steps.fc.outputs.comment-id }}
          issue-number: ${{ github.event.pull_request.number }}
          body: |
            # Benchmarks
            ${{ steps.benchmarks.outputs.body }}
          edit-mode: replace

      - uses: actions-ecosystem/action-remove-labels@v1
        with:
          labels: benchmark

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: Benchmark
 
on:
  pull_request:
    types: [ labeled ]
 
permissions:
  issues: write
  pull-requests: write
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    if: github.event.label.name == 'benchmark'
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: "3.9"
 
      - id: benchmarks
        name: Run Benchmarks
        run: |
          python -m pip install pyperf>=2.3.0
          python extras/profiling/run.py --fresh --complex  --min-speed=6 --file output.txt
          body=$(cat output.txt)
          body="${body//'%'/'%25'}"
          body="${body//$'\n'/'%0A'}"
          body="${body//$'\r'/'%0D'}"
          echo "::set-output name=body::$body"
 
      - name: Find Comment
        uses: peter-evans/find-comment@v2
        id: fc
        with:
          issue-number: ${{ github.event.pull_request.number }}
          comment-author: 'github-actions[bot]'
          body-includes: '# Benchmarks'
 
      - name: Create or update comment
        uses: peter-evans/create-or-update-comment@v2
        with:
          comment-id: ${{ steps.fc.outputs.comment-id }}
          issue-number: ${{ github.event.pull_request.number }}
          body: |
            # Benchmarks
            ${{ steps.benchmarks.outputs.body }}
          edit-mode: replace
 
      - uses: actions-ecosystem/action-remove-labels@v1
        with:
          labels: benchmark
 

What changed

3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow