note 90002 added to function.eval

From: Date: Wed, 01 Apr 2009 16:40:38 +0000
Subject: note 90002 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-152707@lists.php.net to get a copy of this message
@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. ---- Server IP: 66.207.199.35 Probable Submitter: 207.164.214.226 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/90002 Del: integrated -- https://master.php.net/note/delete/90002/integrated Del: useless -- https://master.php.net/note/delete/90002/useless Del: bad code -- https://master.php.net/note/delete/90002/bad+code Del: spam -- https://master.php.net/note/delete/90002/spam Del: non-english -- https://master.php.net/note/delete/90002/non-english Del: in docs -- https://master.php.net/note/delete/90002/in+docs Del: other reasons-- https://master.php.net/note/delete/90002 Reject -- https://master.php.net/note/reject/90002 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152707) next »