Branch Coverage

blib/lib/Data/Throttler.pm
Criterion Covered Total %
branch 53 66 80.3


line true false branch
24 4 3 if ($$self{'db_file'})
43 3 4 if ($$self{'db'}->exists)
50 2 1 if ($$self{'data'}{'chain'} and $$self{'data'}{'chain'}{'max_items'} != $options{'max_items'} || $$self{'data'}{'chain'}{'interval'} != $options{'interval'})
57 1 2 if ($options{'reset'} or not $$self{'db'}->backend_store_ok)
63 6 1 if ($create)
64 0 6 unless $$self{'db'}->create(\%options)
84 2 4 if ($$self{'changed'})
123 26 18 if (exists $options{'key'}) { }
144 3 2 if (exists $options{'key'}) { }
233 0 6 unless ($$self{'max_items'} and $$self{'interval'})
238 6 0 unless ($$self{'nof_buckets'})
242 1 5 if ($$self{'nof_buckets'} > $$self{'interval'})
305 1 120 if $$self{'current_idx'} == $$self{'tail_bucket_idx'}
308 0 120 if $$self{'current_idx'} > $#{$$self{'buckets'};}
330 0 0 unless (scalar keys %{$$b{'count'};})
370 2 1 if $$self{'tail_bucket_idx'} > $#{$$self{'buckets'};}
373 1 2 if $$self{'head_bucket_idx'} > $#{$$self{'buckets'};}
385 0 1 unless defined $time
394 0 1 if ($self->last_bucket->{'time'}{'stop'} >= $time)
403 0 1 if ($$self{'buckets'}[$$self{'tail_bucket_idx'}]{'time'}->max < $time - $$self{'interval'})
432 26 19 if ($$last_bucket{'time'}->member($time))
438 18 121 if ($$b{'time'}->member($time))
455 26 18 if defined $options{'key'}
458 22 22 if defined $options{'time'}
461 0 44 if defined $options{'count'}
467 1 43 unless ($b)
475 38 362 if exists $$self{'buckets'}[$_]{'count'}{$key}
479 9 35 if ($val >= $$self{'max_items'}) { }
499 3 2 if defined $options{'key'}
505 5 45 if (exists $$self{'buckets'}[$_]{'count'}{$key})
583 0 2 unless (-f $$self{'db_file'})
591 0 2 if ($@)
631 0 15 unless open $$self{'fh'}, '+<', $$self{'db_file'}