HOW TO measure execution time of small code snippets?

Discuss everything related to ApPHP MVC Framework. All versions. Any questions related to the Framework developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6153
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO measure execution time of small code snippets?

Postby administrator » Sep 7th, '19, 09:00

To measure execution time of small code snippets you may use a following example of code:

Code: Select all

// Catch start time
startTime = CDebug::getFormattedMicrotime();

// Your code here...

// Catch end time
$endTime = CDebug::getFormattedMicrotime();
// Calculate running time
$totalRunningTime = round((float)$endTime - (float)$startTime, 5);

// Show in debug console
CDebug::console('Total running time: ' . $totalRunningTime);
// Show on the screen
echo 'Total running time: ' . $totalRunningTime;

Return to “ApPHP MVC Framework {developers/users}”