Script to benchmark API execution time.
<?php
error_reporting(E_ALL | E_STRICT);
define('ITERATIONS', 1000000);
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$text = 'node';
function no_op($text) {
return $text;
}
$start = microtime(true);
for ($i=0; $i < ITERATIONS; ++$i) {
}
$stop = microtime(true);
echo "nothing: " . ($stop - $start) . " seconds". PHP_EOL;
$start = microtime(true);
for ($i=0; $i < ITERATIONS; ++$i) {
$url = no_op($text);
}
$stop = microtime(true);
echo "function no_op(): " . ($stop - $start) . " seconds". PHP_EOL;
$start = microtime(true);
for ($i=0; $i < ITERATIONS; ++$i) {
$url = url($text);
}
$stop = microtime(true);
echo "url: " . ($stop - $start) . " seconds". PHP_EOL;
$start = microtime(true);
for ($i=0; $i < ITERATIONS; ++$i) {
}
$stop = microtime(true);
echo "t new: " . ($stop - $start) . " seconds". PHP_EOL;
- 1485 reads
