| 1 | package Devel::FastProf; | ||
| 2 | |||
| 3 | BEGIN { | ||
| 4 | $VERSION = '0.08'; | ||
| 5 | } | ||
| 6 | |||
| 7 | package DB; | ||
| 8 | |||
| 9 | BEGIN { $^P=0x0 } | ||
| 10 | |||
| 11 | sub sub; | ||
| 12 | |||
| 13 | BEGIN { eval "require Time::HiRes" } | ||
| 14 | |||
| 15 | BEGIN { | ||
| 16 | |||
| 17 | require XSLoader; | ||
| 18 | XSLoader::load('Devel::FastProf', $Devel::FastProf::VERSION); | ||
| 19 | |||
| 20 | if ($] < 5.008008) { | ||
| 21 | local $^W = 0; | ||
| 22 | *_DB = \&DB; | ||
| 23 | *DB = sub { goto &_DB } | ||
| 24 | } | ||
| 25 | |||
| 26 | my %config = qw( filename fastprof.out | ||
| 27 | usecputime 0 | ||
| 28 | canfork 0 ); | ||
| 29 | |||
| 30 | if (defined $ENV{FASTPROF_CONFIG}) { | ||
| 31 | for (split /\s*,\s*/, $ENV{FASTPROF_CONFIG}) { | ||
| 32 | if (/^(.*?)\s*=\s*(.*)$/) { | ||
| 33 | $config{$1} = $2; | ||
| 34 | } | ||
| 35 | else { | ||
| 36 | $config{$_} = 1; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | my $fn = $config{filename}; | ||
| 42 | my $cf = $config{canfork}; | ||
| 43 | if ($cf) { | ||
| 44 | unless ($fn =~ m|^/|) { | ||
| 45 | # Oh, yes! | ||
| 46 | # I know about Cwd, but I don't want | ||
| 47 | # to load external modules here!!! | ||
| 48 | my $pwd = `pwd`; | ||
| 49 | chomp ($pwd); | ||
| 50 | $fn = "$pwd/$fn"; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | _init($fn, $config{usecputime}, $cf); | ||
| 55 | |||
| 56 | $^P=0x122 | ||
| 57 | } | ||
| 58 | |||
| 59 | END { | ||
| 60 | { package main; 1 } | ||
| 61 | _finish(); | ||
| 62 | } | ||
| 63 | |||
| 64 | 1; | ||
| 65 | |||
| 66 | |||
| 67 | __END__ |