X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=12ff175029ef10da39ed95116fea66ff13133adb;hb=68fa2f8ae34d78464cb196851a7ce09ebef61b1b;hp=aef8d84c9bc048cc526bbfb9ffd4a2e05e98fc80;hpb=c32a58cabf09c72dd08efca7ff5c49a0adfce71e;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index aef8d84c..12ff1750 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -38,6 +38,7 @@ use VE7CC; use DXXml; use AsyncMsg; use JSON; +use Time::HiRes qw(gettimeofday tv_interval); use Mojo::IOLoop; use Mojo::IOLoop::ForkCall; @@ -1251,6 +1252,23 @@ sub send_motd $self->send_file($motd) if -e $motd; } +sub _diffms +{ + return unless isdbg('chan'); + my $call = shift; + my $line = shift; + my $ta = shift; + my $tb = shift || [gettimeofday]; + + my $a = int($ta->[0] * 1000) + int($ta->[1] / 1000); + my $b = int($tb->[0] * 1000) + int($tb->[1] / 1000); + my $msecs = $b - $a; + + my $s = "forkcall stats: $call '$line' "; + $s .= "${msecs}mS"; + dbg($s); +} + # Punt off a long running command into a separate process # # This is called from commands to run some potentially long running @@ -1261,10 +1279,11 @@ sub send_motd # IT DOES NOT START UP SOME NEW PROGRAM AND RELIES ON THE FACT THAT IT IS RUNNING DXSPIDER # THE CURRENT CONTEXT!! # -# call: $self->spawn_cmd(\, [cb => sub{...}], [prefix => "cmd> "], [progress => 0|1], [args => [...]]); +# call: $self->spawn_cmd($original_cmd_line, \, [cb => sub{...}], [prefix => "cmd> "], [progress => 0|1], [args => [...]]); sub spawn_cmd { my $self = shift; + my $line = shift; my $cmdref = shift; my $call = $self->{call}; my %args = @_; @@ -1274,6 +1293,7 @@ sub spawn_cmd my $prefix = delete $args{prefix}; my $progress = delete $args{progress}; my $args = delete $args{args} || []; + my $t0 = [gettimeofday]; no strict 'refs'; @@ -1304,7 +1324,9 @@ sub spawn_cmd $dxchan->send(@res); } } + _diffms($call, $line, $t0); }); + return @out; }