зеркало из https://github.com/mozilla/gecko-dev.git
Adding &days=n argument.
This commit is contained in:
Родитель
0963eca175
Коммит
c649101a71
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use CGI::Carp qw(fatalsToBrowser);
|
use CGI::Carp qw(fatalsToBrowser);
|
||||||
use CGI::Request;
|
use CGI::Request;
|
||||||
|
use Date::Calc qw(Add_Delta_Days); # http://www.engelschall.com/u/sb/download/Date-Calc/
|
||||||
|
|
||||||
my $req = new CGI::Request;
|
my $req = new CGI::Request;
|
||||||
|
|
||||||
my $TBOX = lc($req->param('tbox'));
|
my $TBOX = lc($req->param('tbox'));
|
||||||
my $AUTOSCALE = lc($req->param('autoscale'));
|
my $AUTOSCALE = lc($req->param('autoscale'));
|
||||||
|
my $DAYS = lc($req->param('days'));
|
||||||
my $DATAFILE = "db/$TBOX";
|
my $DATAFILE = "db/$TBOX";
|
||||||
|
|
||||||
sub make_machine_list {
|
sub make_machine_list {
|
||||||
|
@ -57,7 +59,29 @@ sub show_graph {
|
||||||
die "Can't find gnuplot.";
|
die "Can't find gnuplot.";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Auto-scale y-axis?
|
# Set scaling for x-axis (time)
|
||||||
|
my $xscale;
|
||||||
|
my $today;
|
||||||
|
my $n_days_ago;
|
||||||
|
|
||||||
|
# Get current time, $today.
|
||||||
|
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdat) = localtime();
|
||||||
|
$year += 1900;
|
||||||
|
$mon += 1;
|
||||||
|
$today = sprintf "%04d:%02d:%02d:%02d:%02d:%02d", $year, $mon, $mday, $hour, $min, $sec;
|
||||||
|
|
||||||
|
# Calculate date $DAYS before $today.
|
||||||
|
my ($year2, $mon2, $mday2) = Add_Delta_Days($year, $mon, $mday, -$DAYS);
|
||||||
|
$n_days_ago= sprintf "%04d:%02d:%02d:%02d:%02d:%02d", $year2, $mon2, $mday2, $hour, $min, $sec;
|
||||||
|
|
||||||
|
if($DAYS) {
|
||||||
|
# Assume we want to see 7 days on the graph, so we set the max value also.
|
||||||
|
$xscale = "set xrange [\"$n_days_ago\" : \"$today\"]";
|
||||||
|
} else {
|
||||||
|
$xscale = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set scaling for y-axis.
|
||||||
my $yscale;
|
my $yscale;
|
||||||
if($AUTOSCALE) {
|
if($AUTOSCALE) {
|
||||||
$yscale = "";
|
$yscale = "";
|
||||||
|
@ -76,18 +100,22 @@ sub show_graph {
|
||||||
set linestyle 2 lt 1 lw 1 pt 7 ps 1
|
set linestyle 2 lt 1 lw 1 pt 7 ps 1
|
||||||
set data style points
|
set data style points
|
||||||
set timefmt "%Y:%m:%d:%H:%M:%S"
|
set timefmt "%Y:%m:%d:%H:%M:%S"
|
||||||
$yscale
|
|
||||||
set xdata time
|
set xdata time
|
||||||
set ylabel "XUL Window Open time (msec.)"
|
$xscale
|
||||||
|
$yscale
|
||||||
|
set ylabel "XUL Window Open time (ms)"
|
||||||
set timestamp "Generated: %d/%b/%y %H:%M" 0,0
|
set timestamp "Generated: %d/%b/%y %H:%M" 0,0
|
||||||
set format x "%h %d"
|
set format x "%h %d"
|
||||||
set grid
|
set grid
|
||||||
plot "$DATAFILE" using 1:2 with points ls 1, "$DATAFILE" using 1:2 with lines ls 2
|
plot "$DATAFILE" using 1:2 with points ls 1, "$DATAFILE" using 1:2 with lines ls 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Set up command string for gnuplot
|
||||||
open (GNUPLOT, "| $gnuplot") || die "can't fork: $!";
|
open (GNUPLOT, "| $gnuplot") || die "can't fork: $!";
|
||||||
print GNUPLOT $cmds;
|
print GNUPLOT $cmds;
|
||||||
close (GNUPLOT) || die "can't close: $!";
|
close (GNUPLOT) || die "Empty data set? Gnuplot failed to set up the plot command string : $!";
|
||||||
|
|
||||||
|
# Actually do the gnuplot command.
|
||||||
open (GNUPLOT, "< $PNGFILE") || die "can't read: $!";
|
open (GNUPLOT, "< $PNGFILE") || die "can't read: $!";
|
||||||
{ local $/; $blob = <GNUPLOT>; }
|
{ local $/; $blob = <GNUPLOT>; }
|
||||||
close (GNUPLOT) || die "can't close: $!";
|
close (GNUPLOT) || die "can't close: $!";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче