Profiling JSON request in Rails using Rack Mini Profiler

by Luke, Founder

I often use the rack-mini-profiler gem while developing my Rails applications. It's a ruby gem which provides information in-page about the speed of processing the request. It shows the number of queries and what parts of your code take the longest. I like running it in my dev environment as it helps me to quickly review the performance of each page.

I've needed to review the performance of API requests in the past but have struggled for a recent project it came up again. After a bit of searching, I found out that, if rack mini profiler can't display the results, it will collect them until it can on the next HTML page. So, the solution that I am using is to:

  • make the JSON request and
  • then hit an HTML page of my choice.
  • The results will appear, along with the most recent HTML profile.

It's a little clunky but does the job. I hope it helps someone else.

More articles

The Quotation Bank App — Bringing daily English Literature insights to students

We’re excited to share that **The Quotation Bank App** — developed in partnership with *The Quotation Bank* — is now live on the **App Store and Google Play**.

Read more

Enabling Apple Pay within Stripe Connect accounts

We've been working on a SaaS product for one of our clients and decided to use Stripe Connect to manage platform payments. Stripe Connect enables organizations onboarded into the…

Read more

Ready when you are

Let’s build something together

Whether you’re starting fresh or looking to improve things, we’re ready to talk.