• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 24696162603 / 33
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: perf/build-headers-each-header
DEFAULT BRANCH: master
Ran 20 Apr 2026 11:46PM UTC
Files 154
Run time 5s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

20 Apr 2026 11:44PM UTC coverage: 35.99% (-0.002%) from 35.992%
24696162603.33

Pull #2691

github

ericproulx
Precompute prefix list in Versioner::Path

`Versioner::Path#before` built `[mount_path, Grape::Router.normalize_path(prefix)]`
on every request and iterated it, filtering nil/empty/'/' entries with a guard
clause on each element. Both `mount_path` and `prefix` are fixed at mount time,
so this work is redundant.

Memoize a pre-filtered `@prefixes` array in `initialize` (the middleware dup in
`Middleware::Base#call` shallow-copies ivars, so the frozen array is shared
across request dups for free). The per-request loop simplifies to
`if path_info.start_with?(path)`.

## Benchmark (1k iterations)

  current                    1.09 M i/s, 80KB / 2k objects
  variant A (memoize normalize) 1.34 M i/s, 80KB / 2k objects
  variant B (memoize list)   2.61 M i/s, 40KB / 1k objects  (2.38x faster, 2x fewer)

Shipping variant B.

No behavior change; all 2,236 specs pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull Request #2691: Precompute prefix list in Versioner::Path

33 of 1155 branches covered (2.86%)

Branch coverage included in aggregate %.

1606 of 3399 relevant lines covered (47.25%)

0.69 hits per line

Source Files on job run-4.0-gemfiles/multi_json.gemfile - 24696162603.33
  • Tree
  • List 154
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 24696162603
  • 14068b29 on github
  • Prev Job for on perf/versioner-path-prefix (#24693877550.7)
  • Next Job for on perf/versioner-path-prefix (#24696174073.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc