array())); for ($set=0; $set < SETS; $set++) { // nothing $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { } $stop = microtime(true); if ($set == 0) { $output_header[] = 'nothing'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // theme('username') $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = theme('username', array('account' => $account)); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'theme(username)'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // theme('placeholder') $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = theme('placeholder', array('text' => 'hello')); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'theme(placeholder)'; } $output_rows[$set][] = MILLION*($stop - $start)/ITERATIONS; // theme('table') $header = array('Col-1', 'Col-2'); $rows = array(array('Cell-11', 'Cell-12'), array('Cell-21', 'Cell-22')); $empty_array = array(); $start = microtime(true); for ($i=0; $i < ITERATIONS; ++$i) { $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $empty_array, 'caption' => NULL, 'colgroups' => $empty_array, 'sticky' => TRUE)); } $stop = microtime(true); if ($set == 0) { $output_header[] = 'theme(table)'; } $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)); }