LiTWol @ Oleg Terenchuk

  • Contact
  • Tips & Tricks
  • About me

User login

  • Request new password
To prevent automated spam submissions leave this field empty.

litwol's tweets

  • ... wait let me consult my callendar to see on which day I care. — 2 years 23 weeks ago
  •  
  • 1 of 9
  • ››
more
Home

Script to benchmark API execution time.

Submitted by litwol on Tue, 11/17/2009 - 22:26

<?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;

LiTWoL © Oleg Terenchuk - Hosted on Linode.com 512