CodeIgniter Benchmarking

Benchmarking class is used to calculate the time between two points in your application. This class is initialized automatically by the system so there is no need to do it manually. In addition, the benchmark is always started the moment the framework is invoked, and ended by the output class right before sending the final view to the browser, enabling a very accurate timing of the entire system execution to be shown.

Using the Benchmark Class

The Benchmark class can be used within your controllers, views, or your models. The process for usage is this:

  • Mark a start point.
  • Mark a end point.
  • Run the "elapsed time" function to view the results.

Below an example

  // Some code happens here
  echo $this->benchmark->elapsed_time('code_start', 'code_end');

Displaying Memory Consumption

You can display the amount of memory consumed by the entire system using the following code in one of your view file:

  echo $this->benchmark->memory_usage();