All pastes #77468 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-07-03 01:50 UTC
rendered paste body
<?php

include 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

echo "Initialize 1 million objects: ";
timer_start('object');
for ($i = 0; $i < 1000000; $i++) {
  $object = new stdClass();
}
$stop = timer_stop('object');
echo $stop['time'] ." ms<br />";

echo "Initialize 1 million arrays: ";
timer_start('array');
for ($i = 0; $i < 1000000; $i++) {
  $array = array();
}
$stop = timer_stop('array');
echo $stop['time'] .'ms <br />';

echo "Fetch object: ";
timer_start('fetch_object');
$result = db_query_temporary("SELECT * FROM {node_revision}");
$i = 0;
while ($object = db_fetch_object($result)) {
  $i++;
}
$stop = timer_stop('fetch_object');
echo $stop['time'] .'ms <br />';

echo "Fetch array: ";
timer_start('fetch_array');
$result = db_query_temporary("SELECT * FROM {node_revision}");
$i = 0;
while ($array = db_fetch_array($result)) {
  $i++;
}
$stop = timer_stop('fetch_array');
echo $stop['time'] .'ms <br />';

?>