Apache-Voodoo
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Debug/Handler.pm view on Meta::CPAN
foreach my $row (@{$data}) {
$debug .= '{"level":"'.$row->[0].'"';
$debug .= ',"stack":' .$row->[1];
$debug .= ',"data":';
if ($row->[2] =~ /^[\[\{\"]/) {
$debug .= $row->[2];
}
else {
$debug .= '"'.$row->[2].'"';
}
$debug .= '},';
}
$debug =~ s/,$//;
$debug .= ']';
return $debug;
}
sub handle_profile {
my $self = shift;
my $dbh = shift;
my $params = shift;
my $id = $self->get_request_id($dbh,$params);
unless ($id =~ /^\d+$/) {
return $self->json_error($id);
}
my $res = $dbh->selectall_arrayref("
SELECT
timestamp,
data
FROM
profile
WHERE
request_id = ?
ORDER BY
timestamp",undef,
$id);
my $return;
$return->{'key'} = 'vd_profile';
my $last = $#{$res};
if ($last > 0) {
my $total_time = $res->[$last]->[0] - $res->[0]->[0];
$return->{'value'} = [
map {
[
sprintf("%.5f", $res->[$_]->[0] - $res->[$_-1]->[0]),
sprintf("%5.2f%%",($res->[$_]->[0] - $res->[$_-1]->[0])/$total_time*100),
$res->[$_]->[1]
]
} (1 .. $last)
];
unshift(@{$return->{value}}, [
sprintf("%.5f",$total_time),
'percent',
'message'
]);
}
return $return;
}
1;
################################################################################
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
# All rights reserved.
#
# You may use and distribute Apache::Voodoo under the terms described in the
# LICENSE file include in this package. The summary is it's a legalese version
# of the Artistic License :)
#
################################################################################
( run in 1.093 second using v1.01-cache-2.11-cpan-39bf76dae61 )