|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
DeyV Smarty Rookie
Joined: 01 Jul 2003 Posts: 6 Location: Poland
|
Posted: Tue Jan 11, 2005 11:49 am Post subject: Slow include_once / require_once |
|
|
If some blocks (ex. in method) of code runs more that one times, the include_once can be slow. Why?
Because on all the times work that slow, how include().
Real better method:
[php:1:cf64777e16]<?php
static $bIncCoreGetMicrotime;
if( empty( $bIncCoreGetMicrotime ) ) {
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$bIncCoreGetMicrotime = true;
}
?>[/php:1:cf64777e16]
Last edited by DeyV on Tue Jan 11, 2005 7:53 pm; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jan 11, 2005 4:51 pm Post subject: |
|
|
oh, please show us some numbers how much faster your approach is.
this is very interesting. |
|
Back to top |
|
DeyV Smarty Rookie
Joined: 01 Jul 2003 Posts: 6 Location: Poland
|
Posted: Tue Jan 11, 2005 7:14 pm Post subject: |
|
|
example one:
[php:1:4b3becb60e]<?php
for( $i=0; $i <1000; $i ++ )
{
echo $i. ' ' ;
include_once '1.php';
echo '<br />';
}
?>[/php:1:4b3becb60e]
time: 0.249340057373 s
example two:
[php:1:4b3becb60e]<?php
for( $i=0; $i < 1000; $i ++ )
{
echo $i. ' ' ;
static $bInc;
if( empty( $bInc ) )
{
include_once '1.php';
$bInc = true;
}
echo '<br />';
}
?>[/php:1:4b3becb60e]
time: 0.0045371055603 s
file 1.php
[php:1:4b3becb60e]<?php
function test( ){
echo 'simple test';
}
?>[/php:1:4b3becb60e]
full code and trace from xdebug
http://mstudio.nq.pl/php_pl/index.php?udir=/speed |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|