Application Profiling
Profiling shows where a request spends its time. CodeIgniter includes a debug toolbar that displays timers, database queries, logs, and request data while you develop.
The debug toolbar
In the development environment the toolbar appears at the bottom of HTML responses. It shows:
- Total execution time and memory usage.
- Database queries, including slow ones.
- Request headers and route information.
- Log messages for the current request.
- Loaded files and configuration values.
Configure collectors
The collectors live in app/Config/Toolbar.php. Enable the panels you need and turn the toolbar off in production. It is a development aid, not a production feature.
Read the query log
Look for repeated queries, missing indexes, and queries that load more rows than necessary. A page with dozens of nearly identical queries often needs eager loading or a single joined query.
Profile a specific area
Combine profiling with custom timers (see Benchmarking) to measure a block of code that the toolbar cannot identify by itself.
Checklist
- Test the slowest pages, not only the home page.
- Compare query counts before and after a change.
- Watch memory on pages that load lists or images.
- Turn the toolbar off in production and remove temporary debug statements.