ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Debug.pm
(Generate patch)

Comparing Coro/Coro/Debug.pm (file contents):
Revision 1.113 by root, Thu Dec 13 00:20:40 2012 UTC vs.
Revision 1.114 by root, Fri Feb 8 22:29:18 2013 UTC

104use common::sense; 104use common::sense;
105 105
106use overload (); 106use overload ();
107 107
108use Carp (); 108use Carp ();
109use Time::HiRes ();
110use Scalar::Util (); 109use Scalar::Util ();
111 110
112use Guard; 111use Guard;
113 112
114use AnyEvent (); 113use AnyEvent ();
137 undef 136 undef
138 } 137 }
139} 138}
140 139
141sub format_msg($$) { 140sub format_msg($$) {
142 my ($time, $micro) = Time::HiRes::gettimeofday; 141 my ($time, $micro) = Coro::Util::gettimeofday;
143 my ($sec, $min, $hour, $day, $mon, $year) = gmtime $time; 142 my ($sec, $min, $hour, $day, $mon, $year) = gmtime $time;
144 my $date = sprintf "%04d-%02d-%02dZ%02d:%02d:%02d.%04d", 143 my $date = sprintf "%04d-%02d-%02dZ%02d:%02d:%02d.%04d",
145 $year + 1900, $mon + 1, $day, $hour, $min, $sec, $micro / 100; 144 $year + 1900, $mon + 1, $day, $hour, $min, $sec, $micro / 100;
146 sprintf "%s (%d) %s", $date, $_[0], $_[1] 145 sprintf "%s (%d) %s", $date, $_[0], $_[1]
147} 146}
394 my $cmd = $1; 393 my $cmd = $1;
395 my $sub = eval "sub { $cmd }"; 394 my $sub = eval "sub { $cmd }";
396 my $fh = select; 395 my $fh = select;
397 Coro::async_pool { 396 Coro::async_pool {
398 $Coro::current->{desc} = $cmd; 397 $Coro::current->{desc} = $cmd;
399 my $t = Time::HiRes::time; 398 my $t = Coro::Util::time;
400 my @res = eval { &$sub }; 399 my @res = eval { &$sub };
401 $t = Time::HiRes::time - $t; 400 $t = Coro::Util::time - $t;
402 print {$fh} 401 print {$fh}
403 "\rcommand: $cmd\n", 402 "\rcommand: $cmd\n",
404 "execution time: $t\n", 403 "execution time: $t\n",
405 "result: ", $@ ? $@ : (join " ", @res) . "\n", 404 "result: ", $@ ? $@ : (join " ", @res) . "\n",
406 "> "; 405 "> ";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines