From caf2951c73db15ccd967ee92a36886863897f393 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Tue, 19 Apr 2011 11:04:41 +0000 Subject: send buildtime stats in http header --- index.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 16ffac3..0000fa7 100644 --- a/index.php +++ b/index.php @@ -131,6 +131,10 @@ $r = preg_match_all($re, PREG_SET_ORDER); $pkgs = array(); + +$buildtime_total = 0; +$build_count = 0; + foreach ($matches as $val) { if ($_GET['user'] && ($_GET['user'] != $val[7])) { @@ -171,6 +175,8 @@ foreach ($matches as $val) { $pkgs[$key]['buildtime']['start'] = key2timestamp($val[6]); $pkgs[$key]['buildtime']['end'] = round($val[12]); $pkgs[$key]['buildtime']['diff'] = $pkgs[$key]['buildtime']['end'] - $pkgs[$key]['buildtime']['start']; + $buildtime_total += $pkgs[$key]['buildtime']['diff']; + $build_count += 1; } } // sort by key in reverse order to have more recent pkgs first @@ -222,6 +228,10 @@ if($w < 0) $w = 0; $w = $w * 60; Header("X-BS-Throttle: $w"); + +header(sprintf('X-BS-Buildtime: %d', $buildtime_total)); +$buildtime_avg = round($buildtime_total / $build_count, 2); +header(sprintf('X-BS-Buildtime-Average: %5.2f', $buildtime_avg)); ?> @@ -322,7 +332,7 @@ if ($total > 0) { $s .= ''; if ($p['type'] == 'uploaded') { - $tdiff = timediff($p['buildtime']['start'], $p['buildtime']['end']); + $tdiff = timediff($p['buildtime']['start'], $p['buildtime']['end']); // use $p['buildtime']['diff']; instead? $s .= $tdiff; @$buildtime_stats[$tdiff] += 1; } @@ -385,15 +395,11 @@ if ($total > 0) { uksort($buildtime_stats, "timesort"); $bts = ''; - $buildtime_avg = 0; - $buildtime_cnt = 0; foreach ($buildtime_stats as $time => $count) { $bts .= sprintf('%s%d', $time, $count); $tmp = explode(' ', $time); - $buildtime_avg += $tmp[0] * $count; - $buildtime_cnt += $count; } $s .= ''; @@ -401,8 +407,8 @@ if ($total > 0) { $s .= sprintf('', + $buildtime_total, $buildtime_avg, - round($buildtime_avg / $buildtime_cnt, 1), $buildtime_cnt); $s .= ''; -- cgit v1.2.1
Build time
Total time%s
Average%s
Builds count%s
DurationPack. nb.