Jump to content


Photo

Includes


  • Please log in to reply
6 replies to this topic

#1 johnnyk

johnnyk
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 16 June 2006 - 07:35 PM

I usually keep a file of functions that I regularly use. I include this file on every page. Obviously, not every function is used on every page. Is it bad to include all the functions, considering maybe only 2/5 will be used on any given page. Does it slow down the loading of the page or anything?
Rediscover the Web:
<a href="http://www.spreadfir...;t=219"></a><br />

#2 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 16 June 2006 - 07:51 PM

Yes it will slow down the server some because of the extra script it has to read. But it shouldn't slow it down much if your include file is small. I don't know exactly how much it would slow it down. You would need to run a benchmark on your server to see exactly how much it does slow it down. Just guessing, an include file under 100Kb should be no problem.

Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 June 2006 - 11:21 AM

You probably wont even notice the difference if the file you was including was 10Kb, 100Kb or 1000Kb in size you'll see very little perfomance drop.

It most probably increase your page load by 0.01 secounds or even less. PHP is very fast at processing. You can test how long it may take by doing a quick time trial like so:
<?php

$starttime = microtime();
$startarray = explode(" ", $starttime);
$starttime = $startarray[1] + $startarray[0];

include 'filename.php';

$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = round($endtime - $starttime, 6);

echo '<br /><br />This page loaded in ' . $totaltime . ' seconds';

?>
The bit that take PHP tine will be how long it takes for PHP to run your function.

#4 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 17 June 2006 - 11:41 PM

It's generally good practice to include stuff like that on every script as it means if you have to change something, you only need to change one file rather than every file that relies on whatever you're changing.
[table]



Don't worry, the printer fairies will sort it out.

#5 daiwa

daiwa
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 18 June 2006 - 02:31 AM

if you use a cach optimizer like APC this will be beyond negligeable. but Already odds are it is completely negligeable for your purpose.

#6 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 18 June 2006 - 04:13 PM

If you are not using the ZEND php system and the php has then to recompile every time the page is called, then adding a lot of unneeded functions at the beginning of every page might slow down the page quite a bit. It has been my experience that if you have a php page of any complexity at all, that it takes longer for the server to compile the page then it will then take to execute it! I have found that if you move your php code from a non ZEND system to the ZEND php system, you can expect around a 1.5 to 2 second speedup of your pages! (ZEND rocks!) I in no way work for ZEND.

If you are currently using the ZEND php system, then adding the extra php functions to the beginning of every page should not slow it down because if the functions were already compiled earlier but are not executed in the current page, then they will not slow it down significantly.

#7 johnnyk

johnnyk
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 19 June 2006 - 06:59 PM

Thanks alot for all the info!
Rediscover the Web:
<a href="http://www.spreadfir...;t=219"></a><br />




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users