cvs: php-benchmarks /benchcli/microtests test_array-iterator.php test_array-loop.php
| From: | Alexander Hjalmarsson | Date: | Mon, 29 Jun 2009 19:23:17 +0000 |
| Subject: | cvs: php-benchmarks /benchcli/microtests test_array-iterator.php test_array-loop.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-65146@lists.php.net to get a copy of this message | ||
hjalle Mon Jun 29 19:23:17 2009 UTC
Added files:
/php-benchmarks/benchcli/microtests test_array-loop.php
test_array-iterator.php
Log:
Two small microbenchmarks of arrays.
http://cvs.php.net/viewvc.cgi/php-benchmarks/benchcli/microtests/test_array-loop.php?view=markup&rev=1.1
Index: php-benchmarks/benchcli/microtests/test_array-loop.php
+++ php-benchmarks/benchcli/microtests/test_array-loop.php
<?php
$size = 300000;
// create array
$testArray = array();
for ($i=0; $i<$size; $i++) {
$testArray[$i] = rand(0,9);
}
// loop
for ($i=0; $i<$size; $i++) {
if (isset($testArray[$i])) {
if ($i%2 == 0) {
$testArray[$i] = 'G';
}
}
}
?>
http://cvs.php.net/viewvc.cgi/php-benchmarks/benchcli/microtests/test_array-iterator.php?view=markup&rev=1.1
Index: php-benchmarks/benchcli/microtests/test_array-iterator.php
+++ php-benchmarks/benchcli/microtests/test_array-iterator.php
<?php
$size = 300000;
// create array
$testArray = array();
for ($i=0; $i<$size; $i++) {
$testArray[$i] = rand(0,9);
}
$testObject = new ArrayObject($testArray);
$iterator = $testObject->getIterator();
while ($iterator->valid()) {
if ($iterator->key()%2 == 0) {
$testObject[$iterator->current()] = 'G';
}
$iterator->next();
}
?>