From 161d513dca8099c125b988112fc9531e8537f158 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 6 May 2014 00:14:15 +0800 Subject: Bug 1005959: remove old timing code from show_bug --- Bugzilla/Instrument.pm | 68 -------------------------------------------------- show_bug.cgi | 13 ---------- 2 files changed, 81 deletions(-) delete mode 100644 Bugzilla/Instrument.pm diff --git a/Bugzilla/Instrument.pm b/Bugzilla/Instrument.pm deleted file mode 100644 index 4ab74ff8e..000000000 --- a/Bugzilla/Instrument.pm +++ /dev/null @@ -1,68 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Instrument; - -use strict; -use warnings; - -use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); -use Encode qw(encode_utf8); -use Sys::Syslog qw(:DEFAULT); - -sub new { - my ($class, $label) = @_; - my $self = bless({ times => [], labels => [], values => [] }, $class); - $self->label($label); - $self->time('start_time'); - return $self; -} - -sub time { - my ($self, $name) = @_; - # for now $name isn't used - push @{ $self->{times} }, clock_gettime(CLOCK_MONOTONIC); -} - -sub label { - my ($self, $value) = @_; - push @{ $self->{labels} }, $value; -} - -sub value { - my ($self, $name, $value) = @_; - # for now $name isn't used - push @{ $self->{values} }, $value; -} - -sub log { - my $self = shift; - - my @times = @{ $self->{times} }; - return unless scalar(@times) >= 2; - my @labels = @{ $self->{labels} }; - my @values = @{ $self->{values} }; - - # calculate diffs - my @diffs = ($times[$#times] - $times[0]); - while (1) { - my $start = shift(@times); - last unless scalar(@times); - push @diffs, $times[0] - $start; - } - - # build syslog string - my $format = '[timing]' . (' %s' x scalar(@labels)) . (' %.6f' x scalar(@diffs)) . (' %s' x scalar(@values)); - my $entry = sprintf($format, @labels, @diffs, @values); - - # and log - openlog('apache', 'cons,pid', 'local4'); - syslog('notice', encode_utf8($entry)); - closelog(); -} - -1; diff --git a/show_bug.cgi b/show_bug.cgi index 99679f7ad..332d5fcbd 100755 --- a/show_bug.cgi +++ b/show_bug.cgi @@ -30,16 +30,12 @@ use Bugzilla::Error; use Bugzilla::User; use Bugzilla::Keyword; use Bugzilla::Bug; -use Bugzilla::Instrument; - -my $timings = Bugzilla::Instrument->new('show_bug'); my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; my $vars = {}; my $user = Bugzilla->login(); -$timings->time('login_time'); my $format = $template->get_format("bug/show", scalar $cgi->param('format'), scalar $cgi->param('ctype')); @@ -93,10 +89,8 @@ if ($single) { } } } -$timings->time('load_bug_time'); Bugzilla::Bug->preload(\@bugs); -$timings->time('preload_time'); $vars->{'bugs'} = \@bugs; $vars->{'marks'} = \%marks; @@ -134,10 +128,3 @@ print $cgi->header($format->{'ctype'}); $template->process($format->{'template'}, $vars) || ThrowTemplateError($template->error()); -$timings->time('template_time'); - -if (scalar(@bugids) == 1) { - $timings->label('bug-' . $bugs[0]->id); - $timings->label('user-' . $user->id); - $timings->log(); -} -- cgit v1.2.3-24-g4f1b