Fix profile.pl
[gitmo/Class-MOP.git] / bench / profile.pl
1 #!perl -w
2 # Usage: perl bench/profile.pl (no other options including -Mblib are reqired)
3 use strict;
4
5 my $branch = do{
6         open my $in, '.git/HEAD' or die "Cannot open .git/HEAD: $!";
7         my $s = scalar <$in>;
8         chomp $s;
9         $s =~ s{^ref: \s+ refs/heads/}{}xms;
10         $s =~ s{/}{_}xmsg;
11         $s;
12 };
13
14 my $extra = shift || 'KiokuDB';
15
16 print "Profiling $branch (require $extra) ...\n";
17
18 my @cmd = ($^X, '-Iblib/lib', '-Iblib/arch', '-d:NYTProf', '-e', "require Moose; require $extra");
19 print "> @cmd\n";
20 system(@cmd) == 0 or die "Cannot profile";
21 system(@cmd) == 0 or die "Cannot profile";
22 system(@cmd) == 0 or die "Cannot profile";
23
24 @cmd = ($^X, '-S', 'nytprofhtml', '--out', "nytprof-$branch");
25 print "> @cmd\n";
26 system(@cmd) == 0 or die "Cannot profile";