gecko-dev/tools/performance/startup/measure-simple.pl

89 строки
2.0 KiB
Perl
Исходник Обычный вид История

2001-11-08 06:24:26 +03:00
#!/usr/bin/perl
#
# Script to time mozilla startup
#
# Requirements:
# - a Profile with name "Default User"
# - a MOZ_TIMELINE build
#
# This starts mozilla with the profile "Default User" and makes it quit immediately.
2001-11-09 19:54:22 +03:00
# Measurement is of main1 from MOZ_TIMELINE output
2001-11-08 06:24:26 +03:00
#
# This does multiple runs [default 3] and averages all but the first run.
#
# startup-quick.pl <exe> [n times]
# n - default 3
#
require 5.003;
use strict;
use Cwd;
sub PrintUsage {
die <<END_USAGE
2001-11-08 10:45:32 +03:00
usage: measure-simple.pl [n]
2001-11-08 06:24:26 +03:00
n defaults to 3
2001-11-08 10:45:32 +03:00
e.g
measure-simple.pl ../../../dist/bin/mozilla
measure-simple.pl ../../../dist/bin/mozilla 10
2001-11-08 06:24:26 +03:00
END_USAGE
}
{
PrintUsage() unless $#ARGV >= 0;
my $exe = shift @ARGV;
my $ntimes = shift @ARGV || 3;
my $timelinelog = "timeline.log";
# Do one more than what was requested as we ignore the first run timing
$ntimes++;
# Build up command string.
my $cwd = Cwd::getcwd();
2001-12-01 04:51:41 +03:00
# take care of cygwin adding /cygdrive/<driveletter>
$cwd =~ s/\/cygdrive\/(.)/$1:/;
2001-11-08 06:24:26 +03:00
my $cmd = "$exe -P \"Default User\" file:///$cwd/quit.html";
print "cmd = $cmd\n";
print "$ntimes times\n";
# Setup run environment
2001-12-05 00:48:40 +03:00
$ENV{"NS_TIMELINE_ENABLE"} = 1;
2001-11-08 06:24:26 +03:00
$ENV{"NS_TIMELINE_LOG_FILE"} = $timelinelog;
$ENV{"XPCOM_DEBUG_BREAK"} = "warn";
2001-11-08 10:44:12 +03:00
unlink $timelinelog;
2001-11-08 06:24:26 +03:00
my $i;
my @runtimes = ();
for($i = 0; $i < $ntimes; $i++) {
# Run the command.
system($cmd);
# find the time taken from the TIMELINE LOG
my $F;
open(F, "< $timelinelog") || die "no timeline log ($timelinelog) found";
while(<F>) {
if (/^(.*): \.\.\.main1$/) {
2001-11-08 10:44:12 +03:00
my $t = $1 + 0;
push @runtimes, $t;
2001-11-09 19:54:22 +03:00
print "[$i] startup time : $t sec\n";
2001-11-08 10:44:12 +03:00
last;
2001-11-08 06:24:26 +03:00
}
}
close(F);
2001-11-08 10:44:12 +03:00
# Cleanup
unlink $timelinelog;
2001-11-08 06:24:26 +03:00
}
# Compute final number. Skip first run and average the rest.
my $sum = 0;
shift @runtimes;
foreach $i (@runtimes) {
$sum += $i;
}
2001-11-09 19:54:22 +03:00
printf "Average startup time : %8.4f secs (%d trials - %s)\n", $sum/($ntimes-1), $ntimes-1, join(" ", @runtimes);
2001-11-08 06:24:26 +03:00
}