summaryrefslogtreecommitdiffstats
path: root/show_bug.cgi
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-06-19 10:05:52 +0200
committerByron Jones <bjones@mozilla.com>2013-06-19 10:05:52 +0200
commit8caf466c0cf82a06dc69a29a5e87900e86c2488a (patch)
tree3f1205c3ba63344268199f1678d8063fc8de1b47 /show_bug.cgi
parentc74993e8cb7d8f95f8942e5af57e1fb4b7e1e982 (diff)
downloadbugzilla-8caf466c0cf82a06dc69a29a5e87900e86c2488a.tar.gz
bugzilla-8caf466c0cf82a06dc69a29a5e87900e86c2488a.tar.xz
Bug 884177: updates to the timing collectors
Diffstat (limited to 'show_bug.cgi')
-rwxr-xr-xshow_bug.cgi28
1 files changed, 28 insertions, 0 deletions
diff --git a/show_bug.cgi b/show_bug.cgi
index 332d5fcbd..66d8bdce7 100755
--- a/show_bug.cgi
+++ b/show_bug.cgi
@@ -31,11 +31,18 @@ use Bugzilla::User;
use Bugzilla::Keyword;
use Bugzilla::Bug;
+use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
+use Encode qw(encode_utf8);
+use Sys::Syslog qw(:DEFAULT);
+
+my $timings = { start_time => clock_gettime(CLOCK_MONOTONIC) };
+
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $user = Bugzilla->login();
+$timings->{login_time} = clock_gettime(CLOCK_MONOTONIC);
my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
scalar $cgi->param('ctype'));
@@ -62,6 +69,7 @@ Bugzilla->switch_to_shadow_db unless $user->id;
if ($single) {
my $id = $cgi->param('id');
push @bugs, Bugzilla::Bug->check({ id => $id, cache => 1 });
+ $timings->{load_bug_time} = clock_gettime(CLOCK_MONOTONIC);
if (defined $cgi->param('mark')) {
foreach my $range (split ',', $cgi->param('mark')) {
if ($range =~ /^(\d+)-(\d+)$/) {
@@ -91,6 +99,7 @@ if ($single) {
}
Bugzilla::Bug->preload(\@bugs);
+$timings->{preload_time} = clock_gettime(CLOCK_MONOTONIC);
$vars->{'bugs'} = \@bugs;
$vars->{'marks'} = \%marks;
@@ -128,3 +137,22 @@ print $cgi->header($format->{'ctype'});
$template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error());
+$timings->{template_time} = clock_gettime(CLOCK_MONOTONIC);
+
+_log_timings();
+
+sub _log_timings {
+ return unless scalar(@bugs) == 1;
+ $timings->{end_time} = clock_gettime(CLOCK_MONOTONIC);
+ my $entry = sprintf "show_bug bug-%s user-%s %.6f %.6f %.6f %.6f %.6f",
+ $bugs[0]->id,
+ $user->id,
+ $timings->{end_time} - $timings->{start_time},
+ $timings->{login_time} - $timings->{start_time},
+ $timings->{load_bug_time} - $timings->{login_time},
+ $timings->{preload_time} - $timings->{load_bug_time},
+ $timings->{template_time} - $timings->{preload_time},
+ openlog('apache', 'cons,pid', 'local4');
+ syslog('notice', encode_utf8("[timing] $entry"));
+ closelog();
+}