Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ixudra's avatar

Measure website performance

I'm building a web performance suite for a client which measures stuff like amount of JS files, amount of images, total image size,... for webpages of their clients, so no root access to the webservers. Two of the things I need to measure are 1) total page load time and 2) total website CPU usage. I'm currently trying to figure how this can be done.

Regarding 1) it seems the best option I have is to start a times before doing a cURL request and stop the timer when the request is done. Problem is I'm not sure if that also includes the time it would take to render the page and perform any Javascript operations that get triggered on page load. My guess is no, which would make this a very inaccurate measurement

Number 2) seems just impossible to me. I'd have to profile the machine on which the actual website is running, which seems impossible.

I was just wondering if anyone here had any experience with something similar and could help me out.

0 likes
3 replies
jekinney's avatar

http://php.net/manual/en/function.sys-getloadavg.php

There are other methods to. As far as js load that's a little different as it also client dependent. Meaning clients equipment too. Google analytics does supply the avg page load data. So I THINK you'll have to put a timer start and end (end on ready, window loaded) but send the time data via Ajax back to the server which will not be exact as you will be measuring network latency too.

luceos's avatar

Cpu usage can be measured using the php function sys_getloadavg. Returns an array with three samples (last 1, 5 and 15 minutes).

Regarding the first. I'd simply use curl or a curl wrapper like the well-known guzzle client. You can easily check for resources using a dom crawler like the one from symfony: http://symfony.com/doc/current/components/dom_crawler.html

Please or to participate in this conversation.