Branch Coverage

Shared.xs
Criterion Covered Total %
branch 144 230 62.6


line true false branch
34 6 46 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
37 6 46 if (!h) croak("Data::Histogram::Shared->new: %s", errbuf);
52 3 1 const char *nm = SvOK(name) ? SvPV_nolen(name) : NULL; /* undef -> default label */
55 2 2 if (!h) croak("Data::Histogram::Shared->new_memfd: %s", errbuf);
68 1 1 if (!h) croak("Data::Histogram::Shared->new_from_fd: %s", errbuf);
77 51 0 if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
51 0 if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
79 49 2 if (h) { sv_setiv(SvRV(self), 0); hist_destroy(h); } /* null first: activates EXTRACT's use-after-destroy croak + makes a double DESTROY a no-op */
88 321115 0 EXTRACT(self);
0 321115 EXTRACT(self);
1 321114 EXTRACT(self);
93 1 321113 if (value < 0)
96 1 321112 if (idx < 0)
104 321083 29 RETVAL = total;
113 9 0 EXTRACT(self);
0 9 EXTRACT(self);
0 9 EXTRACT(self);
117 8 1 if (!SvROK(values) || SvTYPE(SvRV(values)) != SVt_PVAV)
1 7 if (!SvROK(values) || SvTYPE(SvRV(values)) != SVt_PVAV)
122 5 2 STRLEN cnt = (top >= 0) ? (STRLEN)(top + 1) : 0, i;
124 5 2 if (cnt) { /* resolve + range-check ALL before locking */
125 0 5 Newx(vals, cnt, int64_t); SAVEFREEPV(vals); /* freed on return OR unwind */
126 1508 2 for (i = 0; i < cnt; i++) { /* a croak here holds NO lock; SAVEFREEPV cleans up */
128 1508 0 IV v = (el && *el) ? SvIV(*el) : 0;
1508 0 IV v = (el && *el) ? SvIV(*el) : 0;
129 1 1507 if (v < 0)
131 2 1505 if (hist_index_for(h, (int64_t)v) < 0)
138 1500 4 for (i = 0; i < cnt; i++) hist_record_locked(h, vals[i], 1);
141 0 4 RETVAL = (UV)cnt;
151 39 0 EXTRACT(self);
0 39 EXTRACT(self);
0 39 EXTRACT(self);
157 30 9 RETVAL = v;
166 28 0 EXTRACT(self);
0 28 EXTRACT(self);
0 28 EXTRACT(self);
170 1 27 if (value < 0)
173 1 26 if (idx < 0)
179 16 10 RETVAL = c;
187 9 0 EXTRACT(self);
0 9 EXTRACT(self);
0 9 EXTRACT(self);
194 8 1 RETVAL = (IV)(total == 0 ? 0 : mn);
0 9 RETVAL = (IV)(total == 0 ? 0 : mn);
202 10 0 EXTRACT(self);
0 10 EXTRACT(self);
0 10 EXTRACT(self);
208 0 10 RETVAL = mx;
216 2 0 EXTRACT(self);
0 2 EXTRACT(self);
0 2 EXTRACT(self);
222 0 2 RETVAL = m;
230 20 0 EXTRACT(self);
0 20 EXTRACT(self);
0 20 EXTRACT(self);
236 0 20 RETVAL = t;
245 6 0 EXTRACT(self);
0 6 EXTRACT(self);
0 6 EXTRACT(self);
247 6 0 if (!sv_isobject(other) || !sv_derived_from(other, "Data::Histogram::Shared"))
0 6 if (!sv_isobject(other) || !sv_derived_from(other, "Data::Histogram::Shared"))
250 0 6 if (!o) croak("Attempted to use a destroyed Data::Histogram::Shared object");
254 6 0 if (o->hdr->lowest != h->hdr->lowest ||
255 5 1 o->hdr->highest != h->hdr->highest ||
256 4 1 o->hdr->sig_figs != h->hdr->sig_figs ||
257 4 0 o->hdr->counts_len != h->hdr->counts_len ||
258 4 0 o->hdr->unit_magnitude != h->hdr->unit_magnitude ||
259 0 4 o->hdr->sub_bucket_mask != h->hdr->sub_bucket_mask)
273 0 4 Newx(tmp, (size_t)counts_len, int64_t);
283 4 0 if (other_total > 0) hist_merge_counts(hist_counts(h), tmp, counts_len); /* empty other -> nothing to add */
284 0 4 if (h->hdr->total_count > INT64_MAX - other_total) h->hdr->total_count = INT64_MAX;
286 4 0 if (other_total > 0) { /* only adopt min/max if other actually recorded something */
287 1 3 if (other_min < h->hdr->min_value) h->hdr->min_value = other_min;
288 3 1 if (other_max > h->hdr->max_value) h->hdr->max_value = other_max;
298 1 0 EXTRACT(self);
0 1 EXTRACT(self);
0 1 EXTRACT(self);
309 3 0 EXTRACT(self);
0 3 EXTRACT(self);
0 3 EXTRACT(self);
311 0 3 RETVAL = (IV)h->hdr->lowest;
319 4 0 EXTRACT(self);
0 4 EXTRACT(self);
0 4 EXTRACT(self);
321 0 4 RETVAL = (IV)h->hdr->highest;
329 4 0 EXTRACT(self);
0 4 EXTRACT(self);
0 4 EXTRACT(self);
331 0 4 RETVAL = (int)h->hdr->sig_figs;
339 6 0 EXTRACT(self);
0 6 EXTRACT(self);
0 6 EXTRACT(self);
341 0 6 RETVAL = (IV)h->hdr->counts_len;
349 3 0 EXTRACT(self);
0 3 EXTRACT(self);
0 3 EXTRACT(self);
377 3 0 hv_stores(hv, "min", newSViv((IV)(total == 0 ? 0 : mn)));
394 3 0 EXTRACT(self);
0 3 EXTRACT(self);
0 3 EXTRACT(self);
396 1 2 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
404 3 0 EXTRACT(self);
0 3 EXTRACT(self);
0 3 EXTRACT(self);
406 0 3 RETVAL = h->backing_fd;
414 2 0 EXTRACT(self);
0 2 EXTRACT(self);
0 2 EXTRACT(self);
416 0 2 if (hist_msync(h) != 0) croak("sync: %s", strerror(errno));
422 1 1 if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
1 0 if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
424 1 0 if (h && h->path) unlink(h->path);
1 0 if (h && h->path) unlink(h->path);
425 1 0 } else if (items >= 2 && SvOK(ST(1))) {
1 0 } else if (items >= 2 && SvOK(ST(1))) {