In this tutorial you will learn about CodeIgniter Benchmarking. If you want to measure the time taken to run a set of lines or to use the memory, you can calculate it using CodeIgniter Benchmarking Points. There is a separate ” Benchmarking ” class in CodeIgniter for this purpose.

This class is automatically loaded; you don’t need to load it. It can be used in controllers, views and model classes anywhere. All you have to do is mark a start and end point and then run the elapsed_time() function between these two marked points and you can get the time it took to run the code as shown below.

   // Some code happens here  

   echo $this->benchmark->elapsed_time('code_start', 'code_end'); 

Use the memory_usage() function as shown in the following code to display the use of memory.

   echo $this->benchmark->memory_usage(); 
Subscribe to our newsletter

You can unsubscribe anytime you want