Re: cvs: phpruntests /code-samples arrayTest.php
| From: | Paul Biggar | Date: | Sun, 21 Jun 2009 18:49:53 +0000 |
| Subject: | Re: cvs: phpruntests /code-samples arrayTest.php | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44394@lists.php.net to get a copy of this message | ||
Hi Georg,
I notice this commit that looks like a benchmark. I'm trying to figure
out if the new run-tests rewrite overlaps with the benchmarks GSoC
project (you might not have been aware since we have the discussions
on php-qa). I wouldn't mind hearing your thoughts so that we avoid
duplicated effort.
Thanks,
Paul
On Sun, Jun 21, 2009 at 6:30 PM, Georg Gradwohl<g2@php.net> wrote:
> g2 Sun Jun 21 17:30:46 2009 UTC
>
> Added files:
> /phpruntests/code-samples arrayTest.php
> Log:
> phpruntests - add arrayTest (spl-performace-test)
>
>
> xžn�-±4Ó
> D×\–|http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/arrayTest.php?view=markup&rev=1.1
> Index: phpruntests/code-samples/arrayTest.php
> +++ phpruntests/code-samples/arrayTest.php
> <?php
>
> $size = isset($argv[1]) ? $argv[1] : 99999;
>
>
> // create array
>
> $testArray = array();
>
> for ($i=0; $i<$size; $i++) {
>
> $testArray[$i] = rand(0,9);
> }
>
> print "size:\t$size\n";
> flush();
>
>
> // loop
>
> $s = microtime(true);
>
> for ($i=0; $i<$size; $i++) {
>
> if (isset($testArray[$i])) {
>
> if ($i%2 == 0) {
>
> $testArray[$i] = 'G';
> }
> }
> }
>
> $e = microtime(true);
>
> $tl = round($e-$s, 5);
>
> print "loop:\t$tl sec (100%)\n";
> flush();
>
>
> // iterator
>
> $s = microtime(true);
>
> $testObject = new ArrayObject($testArray);
> $iterator = $testObject->getIterator();
>
> while ($iterator->valid()) {
>
> if ($iterator->key()%2 == 0) {
>
> $testObject[$iterator->current()] = 'G';
> }
>
> $iterator->next();
> }
>
> $e = microtime(true);
>
> $ti = round($e-$s, 5);
>
> $diff = round($ti/$tl*100, 0);
>
> print "spl:\t$ti sec ($diff%)\n";
> print "DIFF:\t".($ti-$tl)." sec\n";
> flush();
>
>
> ?>
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Paul Biggar
paul.biggar@gmail.com