• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Benchmark: loading base classes slow

#1
[eluser]manelis[/eluser]
Hello,

I have been helping optimize a website that was not created by me, and is using code igniter. Having relatively high first byte times, searching a bit on the web found about the code igniter benchmark, from which I get the following values:


Loading Time: Base Classes 0.2034
Controller Execution Time ( Web / Index ) 0.3622
Total Execution Time 0.5657

The controller time has already been greatly reduced, from near 2 seconds do this, that is still a bit high, but the page is quite heavy on content (and has 6/7 views in it). However, the base classes loading seems to high, comparing to the few examples I can find about it on the internet.

Are these 200ms normal? If not, does anyone know how to reduce it?

Thanks for the help.

#2
[eluser]Tim Brownlaw[/eluser]
Note: The following are "thoughts" and I've not actually done this myself.

The fact that you've managed to bring it down from 2 seconds speaks something about the actual implementation of the original code!

To do this scientifically what you'd need to do is to establish a baseline.
So I'd run a virgin CI setup and do a profile on the welcome page.
In theory that's the quickest it should even run!

I'd be looking in the autoloader to see if there are any unneeded "things" being loaded and only load those items that are required in the actual controller itself.
So you might try ripping out anything unnecessary in the autoloader for this controller in question.

The times you've mentioned seem ok, relatively speaking... But they do seem high! I can only compare that against one of my sites and while I've got a bit going on, I've no clue as to what you have software and hardware wise, so it's hard to say.

It looks like there is some kind of offset happening, but as to where and why, I think you need to look deeper into the code and see what's going on ( rather useful advice you didn't know already! )

Is this running on a nice "Quiet" Development server or a busy Live server?

Without being to add anything further, I'd first establish the baseline times and take it from there.

#3
[eluser]manelis[/eluser]
Sorry for taking so much time to reply, but ive being doing other stuff in the meantime.

So, on the localhost (which doesnt have the database optimizations ive done on the server) I have the following times:

Loading Time: Base Classes 0.3213
Controller Execution Time ( Web / Index ) 1.0615
Total Execution Time 1.3828

As you can see, base classes time is similiar to the one on server.

Ive tried your suggestion and downloaded a clean CI project and get the following:

Loading Time: Base Classes 0.0078
Controller Execution Time ( Welcome / Index ) 0.0020
Total Execution Time 0.0098

Base classes is 42x faster!

Ive also seen autoload as sugested, but I really have nothing special there. I only have the following:

$autoload['libraries'] = array('database','form_validation');
$autoload['helper'] = array('url','form','html');

Everything else is empty.

Is there anything else that can be done to discover the reason?

Than you for the help.

#4
[eluser]Tim Brownlaw[/eluser]
Well other places to check would be the routes.php and the hooks.php in application/config.
Is there anything going on in those?

You could setup/enable xdebug and inspect what it's running! That will give you a better profile of where the alleged "hog" or "hogs" might be.






#5
[eluser]manelis[/eluser]
routes.php:

Code:
$route['default_controller'] = "web";
$route["about"] = 'web/about';
$route["search/(.*)"] = 'web/search/$1';
$route["article/(.*)"] = 'web/article/$1';
$route["view/(.*)"] = 'web/view/$1';
$route["add/(.*)"] = 'web/add/$1';
$route["edit/(.*)"] = 'web/edit/$1';
$route["del/(.*)"] = 'web/del/$1';

hooks is empty. Does these routes affect anything?

In regards to xdebug didnt know about it but doesnt seem imediate to install. Does it run in windows with wamp? I would prefer to not install it on server.

#6
[eluser]Tim Brownlaw[/eluser]
Ok so the routes and hooks are out of the picture...

After you Googled xdebug you may have found this...
http://xdebug.org/wizard.php

To get the phpinfo - create a file on your local server with
Code:
<?php
echo phpinfo();

Copy and paste the output into the wizard and it'll come up with the installation instructions IF you need to install it... ( it might already be installed...)

Then have a little read up on
http://xdebug.org/docs/ and it should get you up and running.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.