'How to measure the execution time of the ruby code inside API controller's action when query is calling
There is an api query that response takes 6 seconds. I am looking in Datadog, and that looks like all SQL queries take an exec time of 2 seconds. What the rest of the time is not clear. Maybe do you know some gems or tools how can I measure the execution time? Many thanks for any advice.
Solution 1:[1]
Solution 2:[2]
Consider rack-mini-profiler.
Features
- Database profiling - Currently supports Mysql2, Postgres, Oracle (oracle_enhanced ~> 1.5.0) and Mongoid3 (with fallback support to ActiveRecord)
- Call-stack profiling - Flame graphs showing time spent by gem
- Memory profiling - Per-request memory usage, GC stats, and global allocation metrics
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Danilo Veloso |
| Solution 2 | Daniel Moskowitz |
