Page load times


(K Buttress) #1

Hello,


We are looking at finding a way to record page loading times, among other things. This is in the frontend and backend. Primarily for a comparison test when we go to upgrade our hardware, in the near future.



I have noticed in the dev.inc file there is a function called speed_check, is this what this function is designed to do, or is there a better way this type of loggin can be implimented.





regards



Kyle


(Avi Miller) #2

The speed_check() function is actually quite useful. You call it at least twice: once to start the clock and the second time to print the time expired since the first call. By default, Matrix prints the time as output to the browser, but there are parameters to send it to the Error Log instead.

In core/web/index.php, if you add as follows:

    speed_check();
    $GLOBALS['SQ_SYSTEM']->start();
    speed_check('', FALSE, TRUE);


Then Matrix will output a total processing time for each call to index.php. The first parameter is a text component that is appended to the time, so you could use that for identification of the page, perhaps.

(Adendle) #3

[quote]The speed_check() function is actually quite useful. You call it at least twice: once to start the clock and the second time to print the time expired since the first call. By default, Matrix prints the time as output to the browser, but there are parameters to send it to the Error Log instead.


In core/web/index.php, if you add as follows:


    speed_check();
    $GLOBALS['SQ_SYSTEM']->start();
    speed_check('', FALSE, TRUE);


Then Matrix will output a total processing time for each call to index.php. The first parameter is a text component that is appended to the time, so you could use that for identification of the page, perhaps.[/quote]

Hi Avi,

is this output (from speed_check()) going to the screen or to the error log file and what format does it take (so we know what to look for).

Thanks :lol: ,
A

(Avi Miller) #4

speed_check('', FALSE, TRUE) sends output to the error log as two numbers, first is "this time", second is "total time" -- essentially it works as a continuous timer from the first speed_check() call that is made. Every subsequent call prints the time since the previous call and the time since the first call. Useful for determining time taken to print each design area, for example (by adding speed_check() calls into the design_file.php created by the parsing process).

Check the PHP Doc header on the function in fudge/dev/dev.inc for more details on each of the parameters.

(K Buttress) #5

Thanks for the information Avi, I would assume then that the mem_check functions in a similar manner, except for the specific memory. Is this dealing with PHP memory or system memory usage
? Are there any issue using these functions at the same time in the same file?


(Greg Sherwood) #6

[quote]Thanks for the information Avi, I would assume then that the mem_check functions in a similar manner, except for the specific memory. Is this dealing with PHP memory or system memory usage
? Are there any issue using these functions at the same time in the same file?[/quote]

It shows PHP memory and is used in the same way. You can use both these functions multiple times in the same file.


(K Buttress) #7

One last request, If I wanted to display the asset id or page that was loaded in the speed_check('show asset id here')


what would be the best way to do that?



Is there an api available for functions like these?


(Avi Miller) #8

It depends on where you've put the speed_check() call. If you put it into the design_file.php that's printing the front-end asset, then you could probably use $ASSET->id at that point. If you're putting the calls into core/web/index.php you may need to do more work to determine the asset id of the currently printing asset.