'placeholder', '#theme' => 'placeholder', '#text' => 'hello'); drupal_render($element); for ($set=0; $set < SETS; $set++) { // simple function call $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = no_op(); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'simple function call'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // url('node') $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = url('node'); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'url(\'node\')'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // theme_markup() $element = element_basic_defaults() + array('#type' => 'markup', '#theme' => 'theme_markup', '#markup' => 'hello'); $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = theme_markup(array('element' => $element)); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'theme_markup()'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // theme('markup') $element = element_basic_defaults() + array('#type' => 'markup', '#theme' => 'theme_markup', '#markup' => 'hello'); $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = theme('markup', $element); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'theme(\'markup\')'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // drupal_render(#markup) $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $element = array('#_type' => 'markup', '#markup' => 'hello'); $output = drupal_render($element); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'drupal_render(#markup)'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // drupal_render(#type=markup) $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $element = array('#type' => 'markup', '#markup' => 'hello'); $output = drupal_render($element); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'drupal_render(#type=markup)'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; } $summary_row = array(); for ($col=0; $col < count($output_rows[0]); $col++) { $a = array(); foreach ($output_rows as $row) { $a[] = $row[$col]; } $avg = average($a); $stdev = stdev($a); $summary_row[$col] = $avg . ' +/- ' . $stdev; } $output_rows[] = $summary_row; print theme('table', array('header' => $output_header, 'rows' => $output_rows)); function average($a) { return array_sum($a) / count($a); } function stdev($a) { $avg = average($a); $variance = array(); foreach ($a as $val) { $variance[] = pow($val-$avg, 2); } return sqrt(average($variance)); }