Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/perf-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ permissions: {}

jobs:
comment:
uses: sferik/duel-ruby/.github/workflows/duel-comment.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel-comment.yml@v0.3.2
permissions:
actions: write # to get the report from the Perf run, and run its Duel job again
pull-requests: write # to comment on the pull request with the report
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Duel and its PostgreSQL plugin. (The Duel jobs run the branch's code,
# so they only read.)
linux:
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.2
permissions:
contents: read
pull-requests: read # for the pull request's labels (see c.accept_label)
Expand All @@ -49,7 +49,7 @@ jobs:
# its programs, and pg's build for pg_config), which Homebrew doesn't
# link it onto.
macos:
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.2
permissions:
contents: read
pull-requests: read
Expand All @@ -69,7 +69,7 @@ jobs:
# rights of the runner's user, an administrator, as postgres needs:
# the binaries' doesn't.
windows:
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel.yml@v0.3.2
permissions:
contents: read
pull-requests: read
Expand All @@ -94,7 +94,7 @@ jobs:
linux-push:
needs: linux
if: ${{ !cancelled() && github.event_name == 'push' }}
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.2
permissions:
contents: write # to comment on the commit, and move the passed branch
with:
Expand All @@ -107,7 +107,7 @@ jobs:
macos-push:
needs: macos
if: ${{ !cancelled() && github.event_name == 'push' }}
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.2
permissions:
contents: write # to comment on the commit, and move the passed branch
with:
Expand All @@ -120,7 +120,7 @@ jobs:
windows-push:
needs: windows
if: ${{ !cancelled() && github.event_name == 'push' }}
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.1
uses: sferik/duel-ruby/.github/workflows/duel-push.yml@v0.3.2
permissions:
contents: write # to comment on the commit, and move the passed branch
with:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ end
group :duel, optional: true do
# Duel requires Ruby 3.4 or later
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4")
gem "duel", "~> 0.3.1"
gem "duel-postgresql", "~> 0.3.1"
gem "duel", "~> 0.3.2"
gem "duel-postgresql", "~> 0.3.2"
gem "pg", force_ruby_platform: true
end
gem "stackprof", platforms: :mri
Expand Down
34 changes: 34 additions & 0 deletions duel/pg_duel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

# Benchmarks, which Duel runs on two versions of the code, the baseline
# (where your branch left main) and the candidate (your changes), and
# fails if the candidate is slower at any of them. Each version's workers
# load pg and every duel/**/*_duel.rb file. See
# https://github.com/sferik/duel-ruby/blob/main/docs/benchmarks.md.
#
# To write benchmarks that tell a regression from noise:
#
# - Benchmark the work that users depend on being fast: the main entry
# points, and whatever runs in a loop or once per request. Cover typical
# inputs, and the small and large extremes, as separate benchmarks.
# - Name each one "area: what it does". `duel --filter "^parse:"` picks
# out an area.
# - Time only the work. Build inputs and read fixtures in `once`, which
# isn't timed. To prepare each sample's work, take |n| (the
# iterations) and wrap the preparation in `untimed`.
# - Make every iteration alike: fixed inputs, seeded randomness
# (Random.new(42)), and caches warmed in `once`. Undo what an
# iteration changes with an `around_iteration` hook, or put it back
# with a `before_sample` hook.
# - Aim for microseconds to a few milliseconds an iteration, and split
# anything slower.
# - Use `judge: :counted` for work that's mostly waiting (on a socket,
# say), and `judge: :timed` for work on threads of its own.
# - Use only the API that the main branch has: a benchmark that the
# baseline can't run is skipped.

# An example, to replace with benchmarks of your own code.
duel "example: join words" do
once { @words = %w[the quick brown fox jumps over the lazy dog] } # not timed
@words.join(" ") # timed
end
Loading