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

Why engineering process is becoming a consultancy’s biggest advantage

As AI makes code faster to produce, the real differentiator for software consultancies is shifting to the engineering process around it.

Read more

Why mobile apps need ongoing support

Getting a mobile app into the App Store and Google Play is not the end of the story. Ongoing support keeps it compatible, reliable and store-ready as platforms change.

Read more
The Azuki team smiling and gathered together, ready to build and collaborate with clients.

Ready when you are

Let’s build something together

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