note 90002 deleted from function.eval by danbrown

From: Date: Wed, 01 Apr 2009 16:49:15 +0000
Subject: note 90002 deleted from function.eval by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152708@lists.php.net to get a copy of this message
Note Submitter: NevarMaor ---- @alexis at amigo dot com re: eval vs include I was curious what effect reading the eval'ed code from a file would have (approximately equivalent to getting the code from a database) rather than setting in the script test.php (rest of code unchanged) <?php ... //execute $code on hundred million times for ($i=0;$i<100000;$i++) { eval(file_get_contents("codefile")); } ... ?> increment.php <?php $increment++; ?> codefile $increment++; Results 1. First I ran "as was" for a benchmark. eval'ed took 1 second include failed - exceeded 30 second max execution time. 2. Lowered 100000 to 20000 (must be a sloooow computer :) "Eval()ed code took 1 seconds to execute 20,000 times. Included file with Pre-parsed code took 9 seconds to execute 20,000 times." 3. Changed eval code to read from file and ran a few times "Eval()ed code took 10 seconds to execute 20,000 times. Included file with Pre-parsed code took 10 seconds to execute 20,000 times." "Eval()ed code took 11 seconds to execute 20,000 times. Included file with Pre-parsed code took 9 seconds to execute 20,000 times." "Eval()ed code took 11 seconds to execute 20,000 times. Included file with Pre-parsed code took 10 seconds to execute 20,000 times." So, if both are reading the code from file (or whatever) they are comparable.

« previous php.notes (#152708) next »