| 1 | package DB::Hooks::TraceSubs; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use IO::Handle; | ||
| 7 | use Time::HiRes qw/ gettimeofday /; | ||
| 8 | open my $stat, ">stat.info"; | ||
| 9 | $stat->autoflush(1); | ||
| 10 | |||
| 11 | |||
| 12 | sub call_handler { | ||
| 13 | # my $t = [ gettimeofday ]; | ||
| 14 | my $fl = join ':', (caller(4))[1..2]; | ||
| 15 | |||
| 16 | $stat->autoflush(1); | ||
| 17 | print $stat "$_[0] > $fl\n"; | ||
| 18 | # DB::x 'main'; 1; | ||
| 19 | # DB::stop 'main'; | ||
| 20 | 1; | ||
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | sub return_handler { | ||
| 25 | # my $t = [ gettimeofday ]; | ||
| 26 | $stat->autoflush(1); | ||
| 27 | print $stat "$_[0] <\n"; | ||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | DB::on( call => \&call_handler ); | ||
| 32 | DB::on( return => \&return_handler ); | ||
| 33 | |||
| 34 | 1; |