Stephen Bugs Kamenar Stephen Bugs Kamenar -3 years ago 104
PHP Question

Why the load speed varies for a CodeIgniter empty page?

I'm loading an empty page with


When I first load the page, I get a controller execution time of 80ms (seems very slow for an empty screen). Then, if I refresh the page quickly the numbers get lower. Around 16ms for controller execution. However, if I wait a few seconds and reload the page, it's slow again.

What's going on here? There is some kind of caching? Is this normal? What numbers are other people getting?

I'm using CodeIgniter version 2.2.0.

Benchmarks for slow loading:

Loading Time: Base Classes 0.0014
Controller Execution Time ( Test / Phpinfo ) 0.0880
Total Execution Time 0.0897

Benchmarks for faster loading:

Loading Time: Base Classes 0.0013
Controller Execution Time ( Test / Phpinfo ) 0.0160
Total Execution Time 0.0175

Answer Source

The server environment, and how busy it is (how many processes are going on at any given millisecond) could affect how fast your page is generated. That said, it does seem like your server is especially slow, which could explain why you see a greater variance. I consider my dev server to be slow, and I get these kind of benchmarks:

Loading Time: Base Classes                   0.0008
Controller Execution Time ( Test / Index )   0.0002
Total Execution Time                         0.0010

For me, total execution time varies between 0.0008 and 0.0016. This kind of variance could be the result of system antivirus, or basically any other program or process doing something. Because PHP and your HTTP server are sharing system resources with everything else on the computer/server, you will see a variance, and that's normal.

If you're curious, you should look into the CPU and memory usage of your computer, and see how it varies, even when you think it is idle.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download