|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-01 10:19 UTC] tiele at staff dot start dot be
Hey, this is not a real feature request or a bug... just something that came to my attention when benchmarking my script. I have added a note on the require() page with the script and some explination. I have a script that requires the use of other php scripts. Some of them over a 1000 times (think of a template for a hyperlink). Normally i would 'require' this file 1000 times but when thinking this over, this would mean that there would be 1000 times disk activity. When storing the contents of that other php script into a string and evaluating this 1000 times i noticed this was 10 to 100 times faster. Perhaps it would be possible to either adjust the require() function or to add require_stick() that would hold this template in it's memory until the main script is done or some flush is done. Just trying to put out a helping hand. Keep it up ! Greets from belgium, Tiele PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jun 18 14:00:02 2026 UTC |
And how right you are... What i've done now is the following: function runtemplate($file) { $file = realpath($file); global $V; if(!function_exists($V[$file])) { $fd = fopen ($file, "r"); $V[$file] = fread($fd, filesize($file)); $V[$file] = "?>".$V[$file]."<?"; $V[$file] = create_function( "", $V[$file] ); fclose ($fd); echo "<td>written as function</td>"; } $V[$file](); } This way i can still call my function with the filename, only has to be opened once and only has to be compile once. 1000x require takes 0.49168002605438 seconds 1000x evaluate takes 0.14559996128082 seconds 1000x running as a function takes 0.038320064544678 seconds !! Thx ! Is there a way i can change my note that i've posted on php.net ? The note i've written is now completely bogus.