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'})
124 26 18 if (exists $options{'key'}) { }
145 3 2 if (exists $options{'key'}) { }
234 0 6 unless ($$self{'max_items'} and $$self{'interval'})
239 6 0 unless ($$self{'nof_buckets'})
243 1 5 if ($$self{'nof_buckets'} > $$self{'interval'})
306 1 120 if $$self{'current_idx'} == $$self{'tail_bucket_idx'}
309 0 120 if $$self{'current_idx'} > $#{$$self{'buckets'};}
331 0 0 unless (scalar keys %{$$b{'count'};})
371 2 1 if $$self{'tail_bucket_idx'} > $#{$$self{'buckets'};}
374 1 2 if $$self{'head_bucket_idx'} > $#{$$self{'buckets'};}
386 0 1 unless defined $time
395 0 1 if ($self->last_bucket->{'time'}{'stop'} >= $time)
404 0 1 if ($$self{'buckets'}[$$self{'tail_bucket_idx'}]{'time'}->max < $time - $$self{'interval'})
433 26 19 if ($$last_bucket{'time'}->member($time))
439 18 121 if ($$b{'time'}->member($time))
456 26 18 if defined $options{'key'}
459 22 22 if defined $options{'time'}
462 0 44 if defined $options{'count'}
468 1 43 unless ($b)
476 38 362 if exists $$self{'buckets'}[$_]{'count'}{$key}
480 9 35 if ($val >= $$self{'max_items'}) { }
500 3 2 if defined $options{'key'}
506 5 45 if (exists $$self{'buckets'}[$_]{'count'}{$key})
584 0 2 unless (-f $$self{'db_file'})
592 0 2 if ($@)
632 0 15 unless open $$self{'fh'}, '+<', $$self{'db_file'}