4 chdir( 't' ) if -d 't';
6 require './test.pl'; # for which_perl() etc
7 require Config; import Config;
8 if ($Config{'extensions'} !~ /\bDevel\/DProf\b/){
9 print "1..0 # Skip: Devel::DProf was not built\n";
15 while(-e 'tmon.out' && unlink 'tmon.out') {}
16 while(-e 'err' && unlink 'err') {}
19 use Benchmark qw( timediff timestr );
20 use Getopt::Std 'getopts';
25 # -p Name of perl binary
27 @tests = @ARGV ? @ARGV : sort (<lib/dprof/*_t>, <lib/dprof/*_v>); # glob-sort, for OS/2
29 $path_sep = $Config{path_sep} || ':';
30 $perl5lib = $opt_I || join( $path_sep, @INC );
31 $perl = $opt_p || which_perl();
34 print "tests: @tests\n";
35 print "perl: $perl\n";
36 print "perl5lib: $perl5lib\n";
38 if( $perl =~ m|^\./| ){
39 # turn ./perl into ../perl, because of chdir(t) above.
42 if( ! -f $perl ){ die "Where's Perl?" }
47 local $ENV{PERL5LIB} = $perl5lib;
48 my $opt_d = '-d:DProf';
50 my $t_start = new Benchmark;
51 open( R, "$perl \"$opt_d\" $test |" ) || warn "$0: Can't run. $!\n";
53 close R or warn "Could not close: $!";
54 my $t_total = timediff( new Benchmark, $t_start );
61 print '# ' . timestr( $t_total, 'nop' ), "\n";
68 my $command = $perl.' "-I../lib" "-I./lib/dprof" '.$test;
69 $command .= ' -v' if $opt_v;
70 $command .= ' -p '. $perl;
79 $test =~ s/\.$// if $^O eq 'VMS';
80 if( $test =~ /_t$/i ){
81 print "# $test" . '.' x (20 - length $test);