Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / tools / performance / startup / measure-simple.pl
blobc0b0c6ca9ac97d7ad42daee2dd16e864eaf551df
1 #!/usr/bin/perl
4 # Script to time mozilla startup
6 # Requirements:
7 # - a Profile with name "Default User"
8 # - a MOZ_TIMELINE build
10 # This starts mozilla with the profile "Default User" and makes it quit immediately.
11 # Measurement is of main1 from MOZ_TIMELINE output
13 # This does multiple runs [default 3] and averages all but the first run.
15 # startup-quick.pl <exe> [n times]
16 # n - default 3
19 require 5.003;
21 use strict;
22 use Cwd;
24 sub PrintUsage {
25 die <<END_USAGE
26 usage: measure-simple.pl [n]
27 n defaults to 3
28 e.g
29 measure-simple.pl ../../../dist/bin/mozilla
30 measure-simple.pl ../../../dist/bin/mozilla 10
31 END_USAGE
35 PrintUsage() unless $#ARGV >= 0;
36 my $exe = shift @ARGV;
37 my $ntimes = shift @ARGV || 3;
38 my $timelinelog = "timeline.log";
39 # Do one more than what was requested as we ignore the first run timing
40 $ntimes++;
42 # Build up command string.
43 my $cwd = Cwd::getcwd();
45 # take care of cygwin adding /cygdrive/<driveletter>
46 $cwd =~ s/\/cygdrive\/(.)/$1:/;
48 my $cmd = "$exe -P \"Default User\" file:///$cwd/quit.html";
49 print "cmd = $cmd\n";
50 print "$ntimes times\n";
52 # Setup run environment
53 $ENV{"NS_TIMELINE_ENABLE"} = 1;
54 $ENV{"NS_TIMELINE_LOG_FILE"} = $timelinelog;
55 $ENV{"XPCOM_DEBUG_BREAK"} = "warn";
56 unlink $timelinelog;
58 my $i;
59 my @runtimes = ();
60 for($i = 0; $i < $ntimes; $i++) {
61 # Run the command.
62 system($cmd);
64 # find the time taken from the TIMELINE LOG
65 my $F;
66 open(F, "< $timelinelog") || die "no timeline log ($timelinelog) found";
67 while(<F>) {
68 if (/^(.*): \.\.\.main1$/) {
69 my $t = $1 + 0;
70 push @runtimes, $t;
71 print "[$i] startup time : $t sec\n";
72 last;
75 close(F);
76 # Cleanup
77 unlink $timelinelog;
80 # Compute final number. Skip first run and average the rest.
81 my $sum = 0;
82 shift @runtimes;
83 foreach $i (@runtimes) {
84 $sum += $i;
86 printf "Average startup time : %8.4f secs (%d trials - %s)\n", $sum/($ntimes-1), $ntimes-1, join(" ", @runtimes);