Member-only story
Why Your Current Test Suite Cannot Catch a 40ms Slowdown
Raza Hussain9 min read·1 hour ago--
The rails performance testing ci setup that catches a 40ms regression before it ships, not after your users do
A 40ms regression shipped to production last week on one of our highest-traffic endpoints. The RSpec suite was green. The PR had two approvals. Nobody caught it because we had no performance regression testing baseline to compare against. Just a vague memory that the endpoint used to be faster.
That is the thing about performance regressions. They do not throw errors. They do not fail your tests. They just make your users wait a little longer every time someone ships a refactor that looked fine in development.
The fix is not faster developers or better code reviews. It is a defined baseline. A set of numbers your CI can compare against on every PR. Here is how to build one.
Unit tests check behavior, not speed. Your RSpec suite verifies that Order#total returns the right number, not that it returns that number in under 8ms.
The gap matters at scale. An endpoint that processed 200 requests per second at 120ms average response time will drop to roughly 160 requests per second if a refactor adds 40ms of ActiveRecord query time. Nothing breaks. No exception fires. The throughput loss shows up in your APM three days later, after a dozen…