-
-#if ( defined(@DBIx::Profile::ISA) && DBIx::Profile::db->can('sprintProfile') ) {
-#if ( defined(@DBIx::Profile::ISA) && UNIVERSAL::can('DBIx::Profile::db', 'sprintProfile') ) {
-if ( defined(@DBIx::Profile::ISA) ) {
-
- #warn "enabling profiling redirects";
- *CGI::redirect = sub {
- my( $self, $location) = @_;
- my $page =
- $cgi->header.
- qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!.
- '<BR><BR><PRE>'.
- ( UNIVERSAL::can(dbh, 'sprintProfile')
- ? encode_entities(dbh->sprintProfile())
- : 'DBIx::Profile missing sprintProfile method;'.
- 'unpatched or too old?' ).
- "\n\n". &sprintAutoProfile(). '</PRE>'.
- '</BODY></HTML>';
- dbh->{'private_profile'} = {};
- return $page;
- };
-
-}
-
-sub by_total_time
-{
- return $a->{total_time_in_sub} <=> $b->{total_time_in_sub};
-}
-
-sub sprintAutoProfile {
- my %caller_info = %Devel::AutoProfiler::caller_info;
- return unless keys %caller_info;
-
- %Devel::AutoProfiler::caller_info = ();
-
- my @keys = keys(%caller_info);
-
- foreach my $key (@keys)
- {
- my $href = $caller_info{$key};
-
- $href->{who_am_i} = $key;
- }
-
- my @subs = values(%caller_info);
-
- #my @sorted = sort by_total_time ( @subs );
- my @sorted = reverse sort by_total_time ( @subs );
-
- # print Dumper \@sorted;
-
- my @readable_info;
-
- foreach my $sort (@sorted)
- {
- push(@readable_info, delete($sort->{who_am_i}));
- push(@readable_info, $sort);
- }
-
- use Data::Dumper;
- return encode_entities(Dumper(\@readable_info));
-
-}
-
-1;
-