Branch Coverage

blib/lib/Algorithm/Classifier/IsolationForest/App/Command/streamd.pm
Criterion Covered Total %
branch 139 252 55.1


line true false branch
208 3 6 if (defined $opt->{'set'} and not $opt->{'set'} =~ /\A[A-Za-z0-9+\-@_]+\z/)
214 0 6 if ($opt->{'save_interval'} < 1)
218 0 6 if (defined $opt->{'keep'} and $opt->{'keep'} < 1)
222 0 0 if (defined $opt->{'threshold'} and $opt->{'threshold'} <= 0 || $opt->{'threshold'} >= 1)
226 0 6 if (defined $opt->{'growth'} and not $opt->{'growth'} =~ /\A(?:adaptive|fixed)\z/)
230 0 6 if (defined $opt->{'socket_mode'} and not $opt->{'socket_mode'} =~ /\A0?[0-7]{3}\z/)
234 0 6 if (defined $opt->{'mungers'})
235 0 0 if (not -f $opt->{'mungers'}) { }
0 0 elsif (not -r $opt->{'mungers'}) { }
0 0 elsif (not defined $opt->{'t'}) { }
244 1 5 if (defined $opt->{'prototype'})
245 0 1 if (not -f $opt->{'prototype'}) { }
0 1 elsif (not -r $opt->{'prototype'}) { }
250 0 1 if (defined $opt->{'t'} or defined $opt->{'mungers'})
264 0 6 unless eval { do { require JSON::MaybeXS; 1 } }
274 3 3 if (defined $OPT{'set'}) { }
275 3 0 defined $OPT{'socket'} ? :
277 3 0 defined $OPT{'pid'} ? :
281 0 3 unless defined $OPT{'socket'}
282 0 3 unless defined $OPT{'pid'}
290 21 3 if defined $OPT{$path_opt}
302 0 6 if length $OPT{'socket'} > 100
310 0 6 if (-e $OPT{'socket'})
312 0 0 if $probe
315 0 6 if (-f $OPT{'pid'})
317 0 0 if defined $old
318 0 0 if (defined $old and $old =~ /\A\d+\z/ and kill(0, $old) || $!{'EPERM'})
326 1 5 if (-e $latest) { }
1 4 elsif (defined $OPT{'prototype'}) { }
328 0 1 unless ref $OIF eq "Algorithm::Classifier::IsolationForest::Online"
334 0 1 if $@
336 0 1 unless $proto->{'class'} eq "online"
339 0 1 if defined $OPT{'n'}
340 0 1 if defined $OPT{'window'}
341 0 1 if defined $OPT{'eta'}
342 0 1 if defined $OPT{'growth'}
343 0 1 if defined $OPT{'subsample'}
344 1 0 if defined $OPT{'s'}
345 0 1 if defined $OPT{'c'}
348 0 1 if $@
351 0 4 if (defined $OPT{'mungers'})
353 0 0 if $@
354 0 0 unless ref $mungers eq "HASH"
374 0 6 unless my $listener = "IO::Socket::UNIX"->new("Local", $OPT{'socket'}, "Listen", 64)
376 0 6 if (defined $OPT{'socket_mode'})
378 0 0 unless chmod oct $OPT{'socket_mode'}, $OPT{'socket'}
381 0 6 unless ($OPT{'f'})
383 0 0 unless defined $OPT{'log'}
408 1 5 -e $latest ? :
3 3 defined $OPT{'set'} ? :
418 0 108 if $timeout < 0
422 24 79 if ($s == $listener)
434 0 108 if ($wsel->count)
440 0 108 if ($REOPEN_LOG)
445 4 104 if ($SAVE_NOW or time >= $next_save)
446 0 1 $SAVE_NOW ? :
1 3 if $DIRTY or $SAVE_NOW
454 2 4 if $DIRTY
473 5 13 unless (-d $dir)
476 0 5 unless -d $dir
486 0 18 unless -w $dir
494 0 0 unless defined(my $pid = fork)
495 0 0 if $pid
496 0 0 unless setsid()
497 0 0 unless defined($pid = fork)
498 0 0 if $pid
499 0 0 unless chdir "/"
500 0 0 unless open STDIN, "<", "/dev/null"
505 3 3 if (defined $OPT{'log'}) { }
506 0 3 unless open my $fh, ">>", $OPT{'log'}
509 0 3 unless ($OPT{'f'})
510 0 0 unless open STDOUT, ">>", $OPT{'log'}
511 0 0 unless open STDERR, ">>", $OPT{'log'}
539 0 6 if (defined $OIF->{'contamination'} and $OIF->window_count)
554 0 6 unless symlink $name, $tmp
556 0 6 unless rename $tmp, "File::Spec"->catfile($OPT{'model_dir'}, "latest.json")
561 0 6 if defined $OPT{'keep'}
566 0 0 unless opendir my $dh, $OPT{'model_dir'}
573 0 0 if unlink $old
593 0 79 unless my $c = $CONN{fileno $s}
596 0 79 unless (defined $got)
597 0 0 if $!{'EAGAIN'} or $!{'EWOULDBLOCK'} or $!{'EINTR'}
600 23 56 if $got == 0
603 0 56 if (length $c->{'inbuf'} > 16777216 and not $c->{'inbuf'} =~ /\n/)
610 0 56 if $line =~ /\A\s*\z/
612 0 56 if length $c->{'outbuf'} > 16777216
614 56 0 if length $c->{'outbuf'}
620 0 56 unless my $c = $CONN{fileno $s}
623 0 56 unless (defined $wrote)
624 0 0 if ($!{'EAGAIN'} or $!{'EWOULDBLOCK'} or $!{'EINTR'})
625 0 0 unless $wsel->exists($s)
632 0 56 if $wsel->exists($s)
647 1 55 if ($@ or ref $msg ne "HASH")
652 18 37 exists $msg->{'tag'} ? :
655 1 54 if (scalar @kinds != 1)
660 21 33 exists $msg->{'mode'} ? :
661 1 53 if (not defined $mode or ref $mode or not $mode =~ /\A(?:prequential|learn|score)\z/)
665 26 27 if ($kind eq "cmd")
669 11 16 $kind eq 'row' ? :
670 0 27 if (ref $rows ne "ARRAY" or not @$rows)
678 4 253 if ($@)
681 3 1 $kind eq 'row' ? :
684 37 216 if defined $score
688 6 17 if ($mode eq "learn")
693 0 36 $_ >= $threshold ? :
694 7 10 if ($kind eq "row")
703 0 26 if not defined $cmd or ref $cmd
705 8 18 if ($cmd eq "ping")
708 1 17 if ($cmd eq "mode")
710 0 1 if (not defined $mode or ref $mode or not $mode =~ /\A(?:prequential|learn|score)\z/)
716 12 5 if ($cmd eq "stats")
727 11 1 defined $OIF->{'n_features'} ? :
9 3 $DIRTY ? :
733 3 2 if ($cmd eq "save")
735 0 3 if ($@)
741 1 1 if ($cmd eq "relearn-threshold")
743 1 0 unless ($ok)
763 0 29 defined $OIF->decision_threshold ? :
0 29 defined $OPT{'threshold'} ? :
779 67 190 if (ref $row eq 'HASH') { }
190 0 elsif (ref $row eq 'ARRAY') { }
783 0 190 if (ref $OIF->{'mungers'} eq "HASH" and %{$OIF->{'mungers'};})
791 0 511 unless defined $vec->[$col]
792 1 510 unless &looks_like_number($vec->[$col])
796 216 38 if ($mode eq "learn")
801 28 10 if ($mode eq "score")