| 1 |
|
| MODULE = Punk::Observe PACKAGE = Punk::Observe::Plot PREFIX = popl_ |
| 2 |
|
| |
| 3 |
|
| # Milliseconds since the epoch, for a chart axis. |
| 4 |
|
| # |
| 5 |
|
| # The last six digits are DROPPED as characters rather than divided away: |
| 6 |
|
| # dividing a nanosecond instant by a million in Perl rounds it BEFORE the |
| 7 |
|
| # division, and the error lands in the digits a chart is drawn from. |
| 8 |
|
| SV * |
| 9 |
|
| popl_ms(SV *ns) |
| 10 |
|
| CODE: |
| 11 |
|
| { |
| 12 |
4 |
| STRLEN len = 0; |
| 13 |
8 |
▶ | const char *p = SvOK(ns) ? SvPV(ns, len) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *p = SvOK(ns) ? SvPV(ns, len) : NULL; |
4 |
0 |
4 |
|
| 14 |
4 |
| po_u64 v = po_plot_ms(p, (size_t)len); |
| 15 |
|
| /* An IV where it fits, as perl's own numification gave, so the JSON |
| 16 |
|
| * says 1787000000000 rather than 1.787e+12. */ |
| 17 |
4 |
▶ | RETVAL = (v <= (po_u64)IV_MAX) ? newSViv((IV)v) : newSVnv((NV)v); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (v <= (po_u64)IV_MAX) ? newSViv((IV)v) : newSVnv((NV)v); |
4 |
0 |
4 |
|
| 18 |
|
| } |
| 19 |
|
| OUTPUT: |
| 20 |
|
| RETVAL |
| 21 |
|
| |
| 22 |
|
| # The bucket width for a window, off a ladder of widths a person recognises. |
| 23 |
|
| SV * |
| 24 |
|
| popl_bucket_for(SV *from, SV *to) |
| 25 |
|
| CODE: |
| 26 |
|
| { |
| 27 |
0 |
| STRLEN fl = 0, tl = 0; |
| 28 |
0 |
▶ | const char *fp = SvOK(from) ? SvPV(from, fl) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *fp = SvOK(from) ? SvPV(from, fl) : NULL; |
0 |
0 |
0 |
|
| 29 |
0 |
▶ | const char *tp = SvOK(to) ? SvPV(to, tl) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *tp = SvOK(to) ? SvPV(to, tl) : NULL; |
0 |
0 |
0 |
|
| 30 |
0 |
| RETVAL = newSVpv(po_plot_bucket_for(fp, (size_t)fl, tp, (size_t)tl), 0); |
| 31 |
|
| } |
| 32 |
|
| OUTPUT: |
| 33 |
|
| RETVAL |
| 34 |
|
| |
| 35 |
|
| SV * |
| 36 |
|
| popl__span_seconds(SV *from, SV *to) |
| 37 |
|
| CODE: |
| 38 |
|
| { |
| 39 |
0 |
| STRLEN fl = 0, tl = 0; |
| 40 |
0 |
▶ | const char *fp = SvOK(from) ? SvPV(from, fl) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *fp = SvOK(from) ? SvPV(from, fl) : NULL; |
0 |
0 |
0 |
|
| 41 |
0 |
▶ | const char *tp = SvOK(to) ? SvPV(to, tl) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *tp = SvOK(to) ? SvPV(to, tl) : NULL; |
0 |
0 |
0 |
|
| 42 |
0 |
| RETVAL = po_u64_to_sv(po_plot_span_seconds(fp, (size_t)fl, tp, (size_t)tl)); |
| 43 |
|
| } |
| 44 |
|
| OUTPUT: |
| 45 |
|
| RETVAL |
| 46 |
|
| |
| 47 |
|
| SV * |
| 48 |
|
| popl__role(int i) |
| 49 |
|
| CODE: |
| 50 |
0 |
| RETVAL = newSVpv(po_plot_role(i), 0); |
| 51 |
|
| OUTPUT: |
| 52 |
|
| RETVAL |
| 53 |
|
| |
| 54 |
|
| SV * |
| 55 |
|
| popl__severity_name(SV *n) |
| 56 |
|
| CODE: |
| 57 |
|
| { |
| 58 |
0 |
| STRLEN len = 0; |
| 59 |
0 |
▶ | const char *p = SvOK(n) ? SvPV(n, len) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *p = SvOK(n) ? SvPV(n, len) : NULL; |
0 |
0 |
0 |
|
| 60 |
|
| char buf[64]; |
| 61 |
0 |
| size_t bn = po_plot_severity_name(p, (size_t)len, buf); |
| 62 |
0 |
| RETVAL = newSVpvn(buf, bn); |
| 63 |
|
| } |
| 64 |
|
| OUTPUT: |
| 65 |
|
| RETVAL |
| 66 |
|
| |
| 67 |
|
| # The x and y arrays for one series, with the holes filled. |
| 68 |
|
| # |
| 69 |
|
| # A HOLE IS NOT A GAP IN A LINE. A bucket with nothing in it is a real answer |
| 70 |
|
| # for a count - nought arrivals - and an UNDEFINED one for a percentile, which |
| 71 |
|
| # is why the caller says which it has rather than this guessing. |
| 72 |
|
| void |
| 73 |
|
| popl__fill_gaps(SV *points, SV *width, SV *zero_fill, SV *from = &PL_sv_undef, SV *to = &PL_sv_undef) |
| 74 |
|
| PPCODE: |
| 75 |
|
| { |
| 76 |
59 |
| AV *px = newAV(), *py = newAV(); |
| 77 |
59 |
| AV *pts = NULL; |
| 78 |
59 |
| SSize_t i, n = 0; |
| 79 |
59 |
| po_u64 step = 0; |
| 80 |
59 |
| int zf = SvTRUE(zero_fill); |
| 81 |
|
| int bounded; |
| 82 |
|
| |
| 83 |
59 |
▶ | if (SvROK(points) && SvTYPE(SvRV(points)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(points) && SvTYPE(SvRV(points)) == SVt_PVAV) |
59 |
0 |
59 |
| if (SvROK(points) && SvTYPE(SvRV(points)) == SVt_PVAV) |
59 |
0 |
59 |
|
| 84 |
59 |
| pts = (AV *)SvRV(points); |
| 85 |
59 |
▶ | n = pts ? av_len(pts) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = pts ? av_len(pts) + 1 : 0; |
59 |
0 |
59 |
|
| 86 |
59 |
▶ | if (!n) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!n) { |
0 |
59 |
59 |
|
| 87 |
0 |
▶ | EXTEND(SP, 2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 2); |
0 |
0 |
0 |
|
| 88 |
0 |
| mPUSHs(newRV_noinc((SV *)px)); |
| 89 |
0 |
| mPUSHs(newRV_noinc((SV *)py)); |
| 90 |
0 |
| XSRETURN(2); |
| 91 |
|
| } |
| 92 |
|
| |
| 93 |
59 |
▶ | if (SvOK(width)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(width)) { |
57 |
2 |
59 |
|
| 94 |
|
| STRLEN wl; |
| 95 |
57 |
| const char *wp = SvPV(width, wl); |
| 96 |
57 |
| step = po_plot_ms(wp, (size_t)wl); |
| 97 |
|
| } |
| 98 |
59 |
▶ | bounded = zf && step && SvOK(from) && SvOK(to); |
Branch: 4 branches
| Branch | True | False | Total |
| bounded = zf && step && SvOK(from) && SvOK(to); |
29 |
30 |
59 |
| bounded = zf && step && SvOK(from) && SvOK(to); |
29 |
0 |
29 |
| bounded = zf && step && SvOK(from) && SvOK(to); |
5 |
24 |
29 |
| bounded = zf && step && SvOK(from) && SvOK(to); |
5 |
0 |
5 |
|
| 99 |
|
| |
| 100 |
|
| /* The instant of a point, as milliseconds. */ |
| 101 |
|
| #define POPL_PT_MS(ix, out) do { \ |
| 102 |
|
| SV **e_ = av_fetch(pts, (ix), 0); \ |
| 103 |
|
| SV **t_ = (e_ && SvROK(*e_) && SvTYPE(SvRV(*e_)) == SVt_PVAV) \ |
| 104 |
|
| ? av_fetch((AV *)SvRV(*e_), 0, 0) : NULL; \ |
| 105 |
|
| STRLEN tl_ = 0; \ |
| 106 |
|
| const char *tp_ = (t_ && SvOK(*t_)) ? SvPV(*t_, tl_) : ""; \ |
| 107 |
|
| (out) = po_plot_ms(tp_, (size_t)tl_); \ |
| 108 |
|
| } while (0) |
| 109 |
|
| |
| 110 |
|
| /* THE EDGES OF THE WINDOW, not only the holes between the points. |
| 111 |
|
| * |
| 112 |
|
| * A window whose data all lands in ONE bucket gives a series of one |
| 113 |
|
| * point, and a one-point line is a moveto with nothing after it: the |
| 114 |
|
| * panel drew an empty box. Worse, plotly had no range to work with |
| 115 |
|
| * and auto-scaled the time axis to that single instant, so a chart |
| 116 |
|
| * titled "the last hour" showed a millisecond either side of it. */ |
| 117 |
59 |
▶ | if (bounded) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (bounded) { |
5 |
54 |
59 |
|
| 118 |
|
| STRLEN fl; |
| 119 |
5 |
| const char *fp = SvPV(from, fl); |
| 120 |
5 |
| po_u64 lo = po_plot_ms(fp, (size_t)fl), first; |
| 121 |
5 |
| SSize_t k = 0; |
| 122 |
10 |
▶ | POPL_PT_MS(0, first); |
Branch: 5 branches
| Branch | True | False | Total |
| POPL_PT_MS(0, first); |
5 |
0 |
5 |
| POPL_PT_MS(0, first); |
5 |
0 |
5 |
| POPL_PT_MS(0, first); |
5 |
0 |
5 |
| POPL_PT_MS(0, first); |
5 |
0 |
5 |
| POPL_PT_MS(0, first); |
5 |
0 |
5 |
|
| 123 |
|
| { |
| 124 |
5 |
| po_u64 t = first; |
| 125 |
147 |
▶ | while (t >= lo + step && k < 200) { t -= step; k++; } |
Branch: 2 branches
| Branch | True | False | Total |
| while (t >= lo + step && k < 200) { t -= step; k++; } |
142 |
5 |
147 |
| while (t >= lo + step && k < 200) { t -= step; k++; } |
142 |
0 |
142 |
|
| 126 |
147 |
▶ | for (; k > 0; k--) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (; k > 0; k--) { |
142 |
5 |
147 |
|
| 127 |
142 |
| av_push(px, po_u64_to_sv(first - (po_u64)k * step)); |
| 128 |
142 |
| av_push(py, newSViv(0)); |
| 129 |
|
| } |
| 130 |
|
| } |
| 131 |
|
| } |
| 132 |
|
| |
| 133 |
|
| { |
| 134 |
59 |
| po_u64 prev = 0; |
| 135 |
59 |
| int have_prev = 0; |
| 136 |
148 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
89 |
59 |
148 |
|
| 137 |
89 |
| SV **e = av_fetch(pts, i, 0); |
| 138 |
|
| AV *row; |
| 139 |
|
| SV **val; |
| 140 |
|
| po_u64 t; |
| 141 |
|
| |
| 142 |
89 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVAV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVAV) continue; |
89 |
0 |
89 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVAV) continue; |
89 |
0 |
89 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVAV) continue; |
0 |
89 |
89 |
|
| 143 |
89 |
| row = (AV *)SvRV(*e); |
| 144 |
178 |
▶ | POPL_PT_MS(i, t); |
Branch: 5 branches
| Branch | True | False | Total |
| POPL_PT_MS(i, t); |
89 |
0 |
89 |
| POPL_PT_MS(i, t); |
89 |
0 |
89 |
| POPL_PT_MS(i, t); |
89 |
0 |
89 |
| POPL_PT_MS(i, t); |
89 |
0 |
89 |
| POPL_PT_MS(i, t); |
89 |
0 |
89 |
|
| 145 |
|
| |
| 146 |
89 |
▶ | if (have_prev && step) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (have_prev && step) { |
30 |
59 |
89 |
| if (have_prev && step) { |
30 |
0 |
30 |
|
| 147 |
|
| /* How many whole buckets were skipped. Done on the |
| 148 |
|
| * millisecond form, which is exact for any gap a chart |
| 149 |
|
| * can show and avoids big-integer arithmetic for |
| 150 |
|
| * something only used to count holes. */ |
| 151 |
30 |
▶ | po_u64 gap = t > prev ? (t - prev) / step : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| po_u64 gap = t > prev ? (t - prev) / step : 0; |
30 |
0 |
30 |
|
| 152 |
|
| po_u64 k; |
| 153 |
30 |
▶ | if (gap) gap--; |
Branch: 1 branch
| Branch | True | False | Total |
| if (gap) gap--; |
30 |
0 |
30 |
|
| 154 |
30 |
▶ | if (gap > 200) gap = 200; /* a hole is a hole */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (gap > 200) gap = 200; /* a hole is a hole */ |
0 |
30 |
30 |
|
| 155 |
39 |
▶ | for (k = 1; k <= gap; k++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (k = 1; k <= gap; k++) { |
9 |
30 |
39 |
|
| 156 |
9 |
| av_push(px, po_u64_to_sv(prev + k * step)); |
| 157 |
9 |
▶ | av_push(py, zf ? newSViv(0) : newSV(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(py, zf ? newSViv(0) : newSV(0)); |
6 |
3 |
9 |
|
| 158 |
|
| } |
| 159 |
|
| } |
| 160 |
|
| |
| 161 |
89 |
| val = av_fetch(row, 1, 0); |
| 162 |
89 |
| av_push(px, po_u64_to_sv(t)); |
| 163 |
89 |
▶ | av_push(py, povw_num(aTHX_ val ? *val : NULL)); |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(py, povw_num(aTHX_ val ? *val : NULL)); |
89 |
0 |
89 |
|
| 164 |
89 |
| prev = t; |
| 165 |
89 |
| have_prev = 1; |
| 166 |
|
| } |
| 167 |
|
| |
| 168 |
59 |
▶ | if (bounded && have_prev) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (bounded && have_prev) { |
5 |
54 |
59 |
| if (bounded && have_prev) { |
5 |
0 |
5 |
|
| 169 |
|
| STRLEN tl; |
| 170 |
5 |
| const char *tp = SvPV(to, tl); |
| 171 |
5 |
| po_u64 hi = po_plot_ms(tp, (size_t)tl); |
| 172 |
5 |
| po_u64 t = prev + step; |
| 173 |
5 |
| int k = 0; |
| 174 |
80 |
▶ | for (; t <= hi && k < 200; t += step, k++) { |
Branch: 2 branches
| Branch | True | False | Total |
| for (; t <= hi && k < 200; t += step, k++) { |
75 |
5 |
80 |
| for (; t <= hi && k < 200; t += step, k++) { |
75 |
0 |
75 |
|
| 175 |
75 |
| av_push(px, po_u64_to_sv(t)); |
| 176 |
75 |
| av_push(py, newSViv(0)); |
| 177 |
|
| } |
| 178 |
|
| } |
| 179 |
|
| } |
| 180 |
|
| #undef POPL_PT_MS |
| 181 |
|
| |
| 182 |
59 |
▶ | EXTEND(SP, 2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 2); |
0 |
59 |
59 |
|
| 183 |
59 |
| mPUSHs(newRV_noinc((SV *)px)); |
| 184 |
59 |
| mPUSHs(newRV_noinc((SV *)py)); |
| 185 |
59 |
| XSRETURN(2); |
| 186 |
|
| } |
| 187 |
|
| |
| 188 |
|
| # AN ABSENT KEY AND A NULL ONE ARE NOT THE SAME THING. |
| 189 |
|
| # |
| 190 |
|
| # A figure that does not want the shared date axis says so with undef, which |
| 191 |
|
| # reads as "drop this". Passed through it encodes as JSON `null`, and a |
| 192 |
|
| # plotting library handed `xaxis: null` does not fall back to its default - it |
| 193 |
|
| # fails, and the panel renders empty with nothing in the markup to show why. |
| 194 |
|
| # |
| 195 |
|
| # So an undef layout entry is REMOVED rather than serialised. A gauge has no |
| 196 |
|
| # axes, and the way to have no axes is to not mention them. |
| 197 |
|
| SV * |
| 198 |
|
| popl__fig(...) |
| 199 |
|
| CODE: |
| 200 |
|
| { |
| 201 |
88 |
| HV *out = newHV(); |
| 202 |
88 |
| HV *layout = newHV(); |
| 203 |
88 |
| AV *data = NULL; |
| 204 |
|
| IV i; |
| 205 |
88 |
| HV *xaxis = newHV(); |
| 206 |
|
| |
| 207 |
|
| /* The base every figure starts from. */ |
| 208 |
88 |
| hv_stores(layout, "hovermode", newSVpvs("x unified")); |
| 209 |
88 |
| hv_stores(xaxis, "type", newSVpvs("date")); |
| 210 |
88 |
| hv_stores(layout, "xaxis", newRV_noinc((SV *)xaxis)); |
| 211 |
|
| |
| 212 |
264 |
▶ | for (i = 0; i + 1 < items; i += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i + 1 < items; i += 2) { |
176 |
88 |
264 |
|
| 213 |
176 |
| const char *k = SvPV_nolen(ST(i)); |
| 214 |
176 |
| SV *v = ST(i + 1); |
| 215 |
176 |
▶ | if (strEQ(k, "data")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(k, "data")) { |
88 |
88 |
176 |
|
| 216 |
88 |
▶ | if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVAV) |
88 |
0 |
88 |
| if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVAV) |
88 |
0 |
88 |
|
| 217 |
88 |
| data = (AV *)SvRV(v); |
| 218 |
|
| } |
| 219 |
88 |
▶ | else if (strEQ(k, "layout") |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "layout") |
88 |
0 |
88 |
|
| 220 |
88 |
▶ | && SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVHV) { |
Branch: 2 branches
| Branch | True | False | Total |
| && SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVHV) { |
88 |
0 |
88 |
| && SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVHV) { |
88 |
0 |
88 |
|
| 221 |
88 |
| HV *l = (HV *)SvRV(v); |
| 222 |
|
| HE *he; |
| 223 |
88 |
| hv_iterinit(l); |
| 224 |
382 |
▶ | while ((he = hv_iternext(l))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((he = hv_iternext(l))) { |
294 |
88 |
382 |
|
| 225 |
|
| STRLEN kl; |
| 226 |
294 |
| char *kp = hv_iterkey(he, (I32 *)&kl); |
| 227 |
294 |
| SV *val = hv_iterval(l, he); |
| 228 |
294 |
▶ | if (!SvOK(val)) { (void)hv_delete(layout, kp, (I32)kl, G_DISCARD); } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(val)) { (void)hv_delete(layout, kp, (I32)kl, G_DISCARD); } |
14 |
280 |
294 |
|
| 229 |
280 |
| else (void)hv_store(layout, kp, (I32)kl, newSVsv(val), 0); |
| 230 |
|
| } |
| 231 |
|
| } |
| 232 |
|
| } |
| 233 |
|
| |
| 234 |
88 |
▶ | hv_stores(out, "data", |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(out, "data", |
88 |
0 |
88 |
|
| 235 |
|
| data ? newRV_inc((SV *)data) : newRV_noinc((SV *)newAV())); |
| 236 |
88 |
| hv_stores(out, "layout", newRV_noinc((SV *)layout)); |
| 237 |
88 |
| RETVAL = newRV_noinc((SV *)out); |
| 238 |
|
| } |
| 239 |
|
| OUTPUT: |
| 240 |
|
| RETVAL |
| 241 |
|
| |
| 242 |
|
| # A LOG AXIS CANNOT DRAW A ZERO, and a chart that silently drops the buckets |
| 243 |
|
| # that saw nothing is a chart claiming the quiet periods did not happen. |
| 244 |
|
| int |
| 245 |
|
| popl__log_is_safe(SV *data) |
| 246 |
|
| CODE: |
| 247 |
|
| { |
| 248 |
0 |
| AV *d = NULL; |
| 249 |
|
| SSize_t i, n; |
| 250 |
0 |
| RETVAL = 1; |
| 251 |
0 |
▶ | if (SvROK(data) && SvTYPE(SvRV(data)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(data) && SvTYPE(SvRV(data)) == SVt_PVAV) |
0 |
0 |
0 |
| if (SvROK(data) && SvTYPE(SvRV(data)) == SVt_PVAV) |
0 |
0 |
0 |
|
| 252 |
0 |
| d = (AV *)SvRV(data); |
| 253 |
0 |
▶ | n = d ? av_len(d) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = d ? av_len(d) + 1 : 0; |
0 |
0 |
0 |
|
| 254 |
0 |
▶ | for (i = 0; i < n && RETVAL; i++) { |
Branch: 2 branches
| Branch | True | False | Total |
| for (i = 0; i < n && RETVAL; i++) { |
0 |
0 |
0 |
| for (i = 0; i < n && RETVAL; i++) { |
0 |
0 |
0 |
|
| 255 |
0 |
| SV **e = av_fetch(d, i, 0); |
| 256 |
|
| SV **y; |
| 257 |
|
| AV *ys; |
| 258 |
|
| SSize_t j, m; |
| 259 |
0 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
0 |
0 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
0 |
0 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
0 |
0 |
|
| 260 |
0 |
| y = hv_fetchs((HV *)SvRV(*e), "y", 0); |
| 261 |
0 |
▶ | if (!y || !SvROK(*y) || SvTYPE(SvRV(*y)) != SVt_PVAV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!y || !SvROK(*y) || SvTYPE(SvRV(*y)) != SVt_PVAV) continue; |
0 |
0 |
0 |
| if (!y || !SvROK(*y) || SvTYPE(SvRV(*y)) != SVt_PVAV) continue; |
0 |
0 |
0 |
| if (!y || !SvROK(*y) || SvTYPE(SvRV(*y)) != SVt_PVAV) continue; |
0 |
0 |
0 |
|
| 262 |
0 |
| ys = (AV *)SvRV(*y); |
| 263 |
0 |
| m = av_len(ys) + 1; |
| 264 |
0 |
▶ | for (j = 0; j < m; j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < m; j++) { |
0 |
0 |
0 |
|
| 265 |
0 |
| SV **v = av_fetch(ys, j, 0); |
| 266 |
0 |
▶ | if (v && SvOK(*v) && SvNV(*v) <= 0) { RETVAL = 0; break; } |
Branch: 3 branches
| Branch | True | False | Total |
| if (v && SvOK(*v) && SvNV(*v) <= 0) { RETVAL = 0; break; } |
0 |
0 |
0 |
| if (v && SvOK(*v) && SvNV(*v) <= 0) { RETVAL = 0; break; } |
0 |
0 |
0 |
| if (v && SvOK(*v) && SvNV(*v) <= 0) { RETVAL = 0; break; } |
0 |
0 |
0 |
|
| 267 |
|
| } |
| 268 |
|
| } |
| 269 |
|
| } |
| 270 |
|
| OUTPUT: |
| 271 |
|
| RETVAL |
| 272 |
|
| |
| 273 |
|
| # One line per series, over time. |
| 274 |
|
| SV * |
| 275 |
|
| popl_timeseries(SV *res, ...) |
| 276 |
|
| CODE: |
| 277 |
|
| { |
| 278 |
26 |
| AV *data = newAV(); |
| 279 |
26 |
| HV *r = NULL; |
| 280 |
|
| SV **f; |
| 281 |
26 |
| SV *width = &PL_sv_undef; |
| 282 |
26 |
| SV *zero_fill = &PL_sv_undef, *fill = NULL, *unit = NULL, *name = NULL; |
| 283 |
26 |
| SV *kind = NULL; |
| 284 |
26 |
| int is_bar = 0, is_area = 0; |
| 285 |
26 |
| int want_log = 0; |
| 286 |
|
| IV a; |
| 287 |
26 |
| SSize_t i, n = 0; |
| 288 |
26 |
| AV *series = NULL; |
| 289 |
|
| |
| 290 |
55 |
▶ | for (a = 1; a + 1 < items; a += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) { |
29 |
26 |
55 |
|
| 291 |
29 |
| const char *k = SvPV_nolen(ST(a)); |
| 292 |
29 |
▶ | if (strEQ(k, "zero_fill")) zero_fill = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(k, "zero_fill")) zero_fill = ST(a + 1); |
3 |
26 |
29 |
|
| 293 |
26 |
▶ | else if (strEQ(k, "fill")) fill = SvOK(ST(a + 1)) ? ST(a + 1) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strEQ(k, "fill")) fill = SvOK(ST(a + 1)) ? ST(a + 1) : NULL; |
0 |
26 |
26 |
| else if (strEQ(k, "fill")) fill = SvOK(ST(a + 1)) ? ST(a + 1) : NULL; |
0 |
0 |
0 |
|
| 294 |
26 |
▶ | else if (strEQ(k, "unit")) unit = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "unit")) unit = ST(a + 1); |
3 |
23 |
26 |
|
| 295 |
23 |
▶ | else if (strEQ(k, "name")) name = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "name")) name = ST(a + 1); |
0 |
23 |
23 |
|
| 296 |
23 |
▶ | else if (strEQ(k, "log")) want_log = SvTRUE(ST(a + 1)); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "log")) want_log = SvTRUE(ST(a + 1)); |
0 |
23 |
23 |
|
| 297 |
|
| /* WHICH SHAPE THE SAME NUMBERS TAKE. A line, the same line with |
| 298 |
|
| * the area under it filled, or a bar per bucket - one builder, |
| 299 |
|
| * because they differ in two attributes and duplicating three |
| 300 |
|
| * hundred lines to change two is how they come to disagree about |
| 301 |
|
| * the axis, the hover or the gaps. */ |
| 302 |
23 |
▶ | else if (strEQ(k, "kind")) kind = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "kind")) kind = ST(a + 1); |
23 |
0 |
23 |
|
| 303 |
|
| } |
| 304 |
|
| |
| 305 |
26 |
▶ | if (kind && SvOK(kind)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (kind && SvOK(kind)) { |
23 |
3 |
26 |
| if (kind && SvOK(kind)) { |
23 |
0 |
23 |
|
| 306 |
23 |
| const char *kp = SvPV_nolen(kind); |
| 307 |
23 |
| is_bar = strEQ(kp, "bar"); |
| 308 |
23 |
| is_area = strEQ(kp, "area"); |
| 309 |
|
| } |
| 310 |
|
| /* `area` IS a filled, stacked line, which is what `fill` already |
| 311 |
|
| * meant. Saying it twice would let a caller ask for an area chart |
| 312 |
|
| * that is not filled. */ |
| 313 |
26 |
▶ | if (is_area && !fill) fill = sv_2mortal(newSVpvs("tozeroy")); |
Branch: 2 branches
| Branch | True | False | Total |
| if (is_area && !fill) fill = sv_2mortal(newSVpvs("tozeroy")); |
3 |
23 |
26 |
| if (is_area && !fill) fill = sv_2mortal(newSVpvs("tozeroy")); |
3 |
0 |
3 |
|
| 314 |
|
| |
| 315 |
26 |
▶ | if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
26 |
0 |
26 |
| if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
26 |
0 |
26 |
|
| 316 |
26 |
▶ | if (r) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (r) { |
26 |
0 |
26 |
|
| 317 |
26 |
| f = hv_fetchs(r, "bucket_ns", 0); |
| 318 |
26 |
▶ | if (f) width = *f; |
Branch: 1 branch
| Branch | True | False | Total |
| if (f) width = *f; |
20 |
6 |
26 |
|
| 319 |
26 |
| f = hv_fetchs(r, "series", 0); |
| 320 |
26 |
▶ | if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
22 |
4 |
26 |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
22 |
0 |
22 |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
22 |
0 |
22 |
|
| 321 |
22 |
| series = (AV *)SvRV(*f); |
| 322 |
|
| } |
| 323 |
26 |
▶ | n = series ? av_len(series) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = series ? av_len(series) + 1 : 0; |
22 |
4 |
26 |
|
| 324 |
|
| |
| 325 |
58 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
32 |
26 |
58 |
|
| 326 |
32 |
| SV **e = av_fetch(series, i, 0); |
| 327 |
|
| HV *s, *trace, *line; |
| 328 |
|
| SV **key, **pts; |
| 329 |
32 |
| SV *xs = NULL, *ys = NULL; |
| 330 |
|
| int got; |
| 331 |
|
| |
| 332 |
32 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
32 |
0 |
32 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
32 |
0 |
32 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
32 |
32 |
|
| 333 |
32 |
| s = (HV *)SvRV(*e); |
| 334 |
32 |
| pts = hv_fetchs(s, "points", 0); |
| 335 |
|
| |
| 336 |
32 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
32 |
32 |
|
| 337 |
32 |
▶ | XPUSHs(sv_2mortal(pts ? newSVsv(*pts) : newRV_noinc((SV *)newAV()))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(pts ? newSVsv(*pts) : newRV_noinc((SV *)newAV()))); |
0 |
32 |
32 |
| XPUSHs(sv_2mortal(pts ? newSVsv(*pts) : newRV_noinc((SV *)newAV()))); |
32 |
0 |
32 |
|
| 338 |
32 |
▶ | XPUSHs(sv_2mortal(newSVsv(width))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(width))); |
0 |
32 |
32 |
|
| 339 |
32 |
▶ | XPUSHs(sv_2mortal(newSVsv(zero_fill))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(zero_fill))); |
0 |
32 |
32 |
|
| 340 |
32 |
| PUTBACK; |
| 341 |
32 |
| got = call_pv("Punk::Observe::Plot::_fill_gaps", G_LIST); |
| 342 |
32 |
| SPAGAIN; |
| 343 |
32 |
▶ | if (got >= 2) { ys = SvREFCNT_inc(POPs); xs = SvREFCNT_inc(POPs); } |
Branch: 1 branch
| Branch | True | False | Total |
| if (got >= 2) { ys = SvREFCNT_inc(POPs); xs = SvREFCNT_inc(POPs); } |
32 |
0 |
32 |
|
| 344 |
0 |
| else { xs = newRV_noinc((SV *)newAV()); ys = newRV_noinc((SV *)newAV()); } |
| 345 |
32 |
| PUTBACK; |
| 346 |
32 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
32 |
0 |
32 |
|
| 347 |
32 |
| SPAGAIN; |
| 348 |
|
| |
| 349 |
32 |
| trace = newHV(); |
| 350 |
32 |
▶ | if (is_bar) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_bar) { |
6 |
26 |
32 |
|
| 351 |
|
| /* A bar has no `mode`; plotly ignores one and a reader |
| 352 |
|
| * grepping the figure should not find a contradiction. */ |
| 353 |
6 |
| hv_stores(trace, "type", newSVpvs("bar")); |
| 354 |
|
| } |
| 355 |
|
| else { |
| 356 |
26 |
| hv_stores(trace, "type", newSVpvs("scatter")); |
| 357 |
26 |
| hv_stores(trace, "mode", newSVpvs("lines")); |
| 358 |
|
| } |
| 359 |
32 |
| key = hv_fetchs(s, "key", 0); |
| 360 |
32 |
▶ | hv_stores(trace, "name", |
Branch: 5 branches
| Branch | True | False | Total |
| hv_stores(trace, "name", |
32 |
0 |
32 |
| hv_stores(trace, "name", |
32 |
0 |
32 |
| hv_stores(trace, "name", |
23 |
9 |
32 |
| hv_stores(trace, "name", |
0 |
9 |
9 |
| hv_stores(trace, "name", |
0 |
0 |
0 |
|
| 361 |
|
| (key && SvOK(*key) && SvCUR(*key)) ? newSVsv(*key) |
| 362 |
|
| : (name && SvOK(name)) ? newSVsv(name) : newSVpvs("value")); |
| 363 |
32 |
| hv_stores(trace, "x", xs); |
| 364 |
32 |
| hv_stores(trace, "y", ys); |
| 365 |
|
| /* NOT connectgaps. An undefined bucket is a hole in the data and |
| 366 |
|
| * joining across it draws a line through a period nothing was |
| 367 |
|
| * measured in. */ |
| 368 |
32 |
| hv_stores(trace, "connectgaps", newSViv(0)); |
| 369 |
32 |
| line = newHV(); |
| 370 |
32 |
| hv_stores(line, "color", newSVpv(po_plot_role((int)i), 0)); |
| 371 |
32 |
| hv_stores(line, "width", newSViv(2)); |
| 372 |
32 |
| hv_stores(trace, "line", newRV_noinc((SV *)line)); |
| 373 |
32 |
▶ | if (fill) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fill) { |
4 |
28 |
32 |
|
| 374 |
4 |
| hv_stores(trace, "fill", newSVsv(fill)); |
| 375 |
4 |
| hv_stores(trace, "stackgroup", newSVpvs("one")); |
| 376 |
|
| } |
| 377 |
32 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 378 |
|
| } |
| 379 |
|
| |
| 380 |
|
| { |
| 381 |
26 |
| HV *layout = newHV(), *yaxis = newHV(), *title = newHV(); |
| 382 |
|
| SV *args[4]; |
| 383 |
|
| SV *safe; |
| 384 |
|
| int got; |
| 385 |
26 |
| int logsafe = 0; |
| 386 |
|
| |
| 387 |
26 |
▶ | if (want_log) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (want_log) { |
0 |
26 |
26 |
|
| 388 |
0 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
0 |
0 |
|
| 389 |
0 |
▶ | XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
0 |
0 |
0 |
|
| 390 |
0 |
| PUTBACK; |
| 391 |
0 |
| got = call_pv("Punk::Observe::Plot::_log_is_safe", G_SCALAR); |
| 392 |
0 |
| SPAGAIN; |
| 393 |
|
| /* Popped into a variable first: before 5.32 SvTRUE mentions |
| 394 |
|
| * its argument up to five times, and SvTRUE(POPs) pops once |
| 395 |
|
| * per mention. */ |
| 396 |
0 |
▶ | if (got) { safe = POPs; logsafe = SvTRUE(safe) ? 1 : 0; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (got) { safe = POPs; logsafe = SvTRUE(safe) ? 1 : 0; } |
0 |
0 |
0 |
|
| 397 |
0 |
| PUTBACK; |
| 398 |
0 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
0 |
0 |
0 |
|
| 399 |
0 |
| SPAGAIN; |
| 400 |
|
| } |
| 401 |
|
| |
| 402 |
26 |
▶ | hv_stores(title, "text", |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(title, "text", |
3 |
23 |
26 |
| hv_stores(title, "text", |
3 |
0 |
3 |
|
| 403 |
|
| (unit && SvOK(unit)) ? newSVsv(unit) : newSVpvs("")); |
| 404 |
26 |
| hv_stores(yaxis, "title", newRV_noinc((SV *)title)); |
| 405 |
26 |
| hv_stores(yaxis, "rangemode", newSVpvs("tozero")); |
| 406 |
26 |
▶ | if (want_log && logsafe) hv_stores(yaxis, "type", newSVpvs("log")); |
Branch: 2 branches
| Branch | True | False | Total |
| if (want_log && logsafe) hv_stores(yaxis, "type", newSVpvs("log")); |
0 |
26 |
26 |
| if (want_log && logsafe) hv_stores(yaxis, "type", newSVpvs("log")); |
0 |
0 |
0 |
|
| 407 |
|
| /* STACKED, NOT OVERLAID. Two series of bars drawn on top of each |
| 408 |
|
| * other hide one of them completely, and the reader cannot tell |
| 409 |
|
| * that is what happened. */ |
| 410 |
26 |
▶ | if (is_bar) hv_stores(layout, "barmode", newSVpvs("stack")); |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_bar) hv_stores(layout, "barmode", newSVpvs("stack")); |
5 |
21 |
26 |
|
| 411 |
26 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 412 |
|
| /* One series needs no legend: the heading already names it. */ |
| 413 |
26 |
| hv_stores(layout, "showlegend", |
| 414 |
|
| newRV_noinc(newSViv(av_len(data) > 0 ? 1 : 0))); |
| 415 |
|
| |
| 416 |
26 |
| args[0] = sv_2mortal(newSVpvs("data")); |
| 417 |
26 |
| args[1] = sv_2mortal(newRV_inc((SV *)data)); |
| 418 |
26 |
| args[2] = sv_2mortal(newSVpvs("layout")); |
| 419 |
26 |
| args[3] = sv_2mortal(newRV_noinc((SV *)layout)); |
| 420 |
|
| |
| 421 |
26 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
26 |
26 |
|
| 422 |
130 |
▶ | { int k; for (k = 0; k < 4; k++) XPUSHs(args[k]); } |
Branch: 2 branches
| Branch | True | False | Total |
| { int k; for (k = 0; k < 4; k++) XPUSHs(args[k]); } |
0 |
104 |
104 |
| { int k; for (k = 0; k < 4; k++) XPUSHs(args[k]); } |
104 |
26 |
130 |
|
| 423 |
26 |
| PUTBACK; |
| 424 |
26 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 425 |
26 |
| SPAGAIN; |
| 426 |
26 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
26 |
0 |
26 |
|
| 427 |
26 |
| PUTBACK; |
| 428 |
26 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
26 |
0 |
26 |
|
| 429 |
26 |
| SPAGAIN; |
| 430 |
|
| } |
| 431 |
26 |
| SvREFCNT_dec((SV *)data); |
| 432 |
|
| } |
| 433 |
|
| OUTPUT: |
| 434 |
|
| RETVAL |
| 435 |
|
| |
| 436 |
|
| # A number for a table cell. |
| 437 |
|
| SV * |
| 438 |
|
| popl__num(SV *v) |
| 439 |
|
| CODE: |
| 440 |
|
| { |
| 441 |
|
| double d; |
| 442 |
|
| char buf[64]; |
| 443 |
|
| int n; |
| 444 |
|
| |
| 445 |
|
| /* ONE EXIT. An XSRETURN inside a CODE: block returns before xsubpp |
| 446 |
|
| * pushes RETVAL, so the caller gets whatever was on the stack - which |
| 447 |
|
| * is the argument. */ |
| 448 |
47 |
▶ | if (!SvOK(v)) RETVAL = newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(v)) RETVAL = newSVpvs(""); |
0 |
47 |
47 |
|
| 449 |
|
| else { |
| 450 |
47 |
| d = (double)SvNV(v); |
| 451 |
|
| /* Whole numbers print whole, however large - counts are the |
| 452 |
|
| * common case here and "951" is the answer, not "951.000". */ |
| 453 |
47 |
▶ | if (d == (double)(po_i64)d && (d < 1e15 && d > -1e15)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (d == (double)(po_i64)d && (d < 1e15 && d > -1e15)) |
47 |
0 |
47 |
| if (d == (double)(po_i64)d && (d < 1e15 && d > -1e15)) |
47 |
0 |
47 |
| if (d == (double)(po_i64)d && (d < 1e15 && d > -1e15)) |
47 |
0 |
47 |
|
| 454 |
47 |
| RETVAL = newSVpvf("%.0" NVff, (NV)d); |
| 455 |
|
| else { |
| 456 |
0 |
▶ | n = my_snprintf(buf, sizeof(buf), |
Branch: 1 branch
| Branch | True | False | Total |
| n = my_snprintf(buf, sizeof(buf), |
0 |
0 |
0 |
|
| 457 |
0 |
▶ | ((d < 1 && d > -1) ? "%.6f" : "%.3f"), d); |
Branch: 1 branch
| Branch | True | False | Total |
| ((d < 1 && d > -1) ? "%.6f" : "%.3f"), d); |
0 |
0 |
0 |
|
| 458 |
0 |
▶ | if (n < 0) n = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (n < 0) n = 0; |
0 |
0 |
0 |
|
| 459 |
0 |
▶ | if ((size_t)n >= sizeof(buf)) n = (int)sizeof(buf) - 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if ((size_t)n >= sizeof(buf)) n = (int)sizeof(buf) - 1; |
0 |
0 |
0 |
|
| 460 |
|
| /* A trailing run of zeroes, then a bare point. `%.6f` of 0.5 |
| 461 |
|
| * is 0.500000 and the cell wants 0.5. */ |
| 462 |
0 |
▶ | while (n > 0 && buf[n - 1] == '0') n--; |
Branch: 2 branches
| Branch | True | False | Total |
| while (n > 0 && buf[n - 1] == '0') n--; |
0 |
0 |
0 |
| while (n > 0 && buf[n - 1] == '0') n--; |
0 |
0 |
0 |
|
| 463 |
0 |
▶ | if (n > 0 && buf[n - 1] == '.') n--; |
Branch: 2 branches
| Branch | True | False | Total |
| if (n > 0 && buf[n - 1] == '.') n--; |
0 |
0 |
0 |
| if (n > 0 && buf[n - 1] == '.') n--; |
0 |
0 |
0 |
|
| 464 |
0 |
| RETVAL = newSVpvn(buf, (STRLEN)n); |
| 465 |
|
| } |
| 466 |
|
| } |
| 467 |
|
| } |
| 468 |
|
| OUTPUT: |
| 469 |
|
| RETVAL |
| 470 |
|
| |
| 471 |
|
| # A figure as JSON, for a <script> tag. |
| 472 |
|
| # |
| 473 |
|
| # `</` IS ESCAPED, and that is not decoration: an HTML parser ends a <script> |
| 474 |
|
| # element at the first `</` whatever the JSON around it says, so a log line |
| 475 |
|
| # containing `</script>` would close the tag and put the rest of the figure |
| 476 |
|
| # into the document as markup. Done in one pass here rather than as a global |
| 477 |
|
| # regex over what can be a multi-megabyte string. |
| 478 |
|
| SV * |
| 479 |
|
| popl_encode(SV *fig) |
| 480 |
|
| CODE: |
| 481 |
|
| { |
| 482 |
90 |
| SV *json = NULL; |
| 483 |
|
| int n; |
| 484 |
|
| |
| 485 |
90 |
▶ | if (!SvROK(fig)) { RETVAL = newSVpvs(""); goto done; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvROK(fig)) { RETVAL = newSVpvs(""); goto done; } |
2 |
88 |
90 |
|
| 486 |
|
| |
| 487 |
88 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
88 |
88 |
|
| 488 |
88 |
▶ | XPUSHs(fig); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(fig); |
0 |
88 |
88 |
|
| 489 |
88 |
| PUTBACK; |
| 490 |
88 |
| n = call_pv("File::Raw::JSON::file_json_encode", G_SCALAR | G_EVAL); |
| 491 |
88 |
| SPAGAIN; |
| 492 |
88 |
▶ | json = n ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| json = n ? SvREFCNT_inc(POPs) : NULL; |
88 |
0 |
88 |
|
| 493 |
88 |
| PUTBACK; |
| 494 |
88 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
88 |
0 |
88 |
|
| 495 |
88 |
| SPAGAIN; |
| 496 |
|
| |
| 497 |
88 |
▶ | if (SvTRUE(ERRSV) || !json || !SvOK(json)) { |
Branch: 4 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV) || !json || !SvOK(json)) { |
88 |
0 |
88 |
| if (SvTRUE(ERRSV) || !json || !SvOK(json)) { |
88 |
0 |
88 |
| if (SvTRUE(ERRSV) || !json || !SvOK(json)) { |
88 |
0 |
88 |
| if (SvTRUE(ERRSV) || !json || !SvOK(json)) { |
0 |
88 |
88 |
|
| 498 |
0 |
▶ | if (json) SvREFCNT_dec(json); |
Branch: 1 branch
| Branch | True | False | Total |
| if (json) SvREFCNT_dec(json); |
0 |
0 |
0 |
|
| 499 |
0 |
| RETVAL = newSVpvs(""); |
| 500 |
0 |
| goto done; |
| 501 |
|
| } |
| 502 |
|
| |
| 503 |
|
| { |
| 504 |
|
| STRLEN len; |
| 505 |
88 |
| const char *p = SvPV(json, len); |
| 506 |
88 |
| const char *end = p + len; |
| 507 |
88 |
| const char *run = p; |
| 508 |
88 |
| SV *out = newSVpvn("", 0); |
| 509 |
|
| /* Grown once: the escape adds one byte per occurrence and there |
| 510 |
|
| * are usually none at all. */ |
| 511 |
88 |
▶ | (void)SvGROW(out, len + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| (void)SvGROW(out, len + 1); |
88 |
0 |
88 |
| (void)SvGROW(out, len + 1); |
88 |
0 |
88 |
|
| 512 |
60730 |
▶ | while (p < end) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p < end) { |
60642 |
88 |
60730 |
|
| 513 |
60642 |
▶ | if (*p == '<' && p + 1 < end && p[1] == '/') { |
Branch: 3 branches
| Branch | True | False | Total |
| if (*p == '<' && p + 1 < end && p[1] == '/') { |
86 |
60556 |
60642 |
| if (*p == '<' && p + 1 < end && p[1] == '/') { |
86 |
0 |
86 |
| if (*p == '<' && p + 1 < end && p[1] == '/') { |
43 |
43 |
86 |
|
| 514 |
43 |
| sv_catpvn(out, run, (STRLEN)(p - run + 1)); |
| 515 |
43 |
| sv_catpvs(out, "\\/"); |
| 516 |
43 |
| p += 2; |
| 517 |
43 |
| run = p; |
| 518 |
43 |
| continue; |
| 519 |
|
| } |
| 520 |
60599 |
| p++; |
| 521 |
|
| } |
| 522 |
88 |
▶ | if (run < end) sv_catpvn(out, run, (STRLEN)(end - run)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (run < end) sv_catpvn(out, run, (STRLEN)(end - run)); |
88 |
0 |
88 |
|
| 523 |
88 |
▶ | if (SvUTF8(json)) SvUTF8_on(out); |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvUTF8(json)) SvUTF8_on(out); |
0 |
88 |
88 |
|
| 524 |
88 |
| SvREFCNT_dec(json); |
| 525 |
88 |
| RETVAL = out; |
| 526 |
|
| } |
| 527 |
90 |
| done: ; |
| 528 |
|
| } |
| 529 |
|
| OUTPUT: |
| 530 |
|
| RETVAL |
| 531 |
|
| |
| 532 |
|
| # ONE BAR PER GROUP, HORIZONTAL. An aggregate with no time dimension has no |
| 533 |
|
| # shape over time, and drawing it as a line would be a chart claiming one. |
| 534 |
|
| SV * |
| 535 |
|
| popl_bars(SV *groups, ...) |
| 536 |
|
| CODE: |
| 537 |
|
| { |
| 538 |
5 |
| AV *xs = newAV(), *ys = newAV(); |
| 539 |
5 |
| AV *g = NULL; |
| 540 |
5 |
| HV *trace = newHV(), *marker = newHV(), *layout = newHV(); |
| 541 |
5 |
| HV *xaxis = newHV(), *yaxis = newHV(), *title = newHV(), *margin = newHV(); |
| 542 |
5 |
| AV *data = newAV(); |
| 543 |
5 |
| SV *unit = NULL; |
| 544 |
|
| SSize_t i, n; |
| 545 |
|
| IV a; |
| 546 |
|
| int got; |
| 547 |
|
| |
| 548 |
5 |
▶ | for (a = 1; a + 1 < items; a += 2) |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) |
0 |
5 |
5 |
|
| 549 |
0 |
▶ | if (strEQ(SvPV_nolen(ST(a)), "unit")) unit = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(SvPV_nolen(ST(a)), "unit")) unit = ST(a + 1); |
0 |
0 |
0 |
|
| 550 |
|
| |
| 551 |
5 |
▶ | if (SvROK(groups) && SvTYPE(SvRV(groups)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(groups) && SvTYPE(SvRV(groups)) == SVt_PVAV) |
5 |
0 |
5 |
| if (SvROK(groups) && SvTYPE(SvRV(groups)) == SVt_PVAV) |
5 |
0 |
5 |
|
| 552 |
5 |
| g = (AV *)SvRV(groups); |
| 553 |
5 |
▶ | n = g ? av_len(g) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = g ? av_len(g) + 1 : 0; |
5 |
0 |
5 |
|
| 554 |
12 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
7 |
5 |
12 |
|
| 555 |
7 |
| SV **e = av_fetch(g, i, 0); |
| 556 |
|
| HV *h; |
| 557 |
|
| SV **k, **v; |
| 558 |
7 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
7 |
0 |
7 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
7 |
0 |
7 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
7 |
7 |
|
| 559 |
7 |
| h = (HV *)SvRV(*e); |
| 560 |
7 |
| k = hv_fetchs(h, "key", 0); |
| 561 |
|
| /* A group whose key is empty is still a group. `(none)` names it |
| 562 |
|
| * rather than leaving a blank row nobody can click. */ |
| 563 |
7 |
▶ | av_push(ys, (k && SvOK(*k) && SvCUR(*k)) ? newSVsv(*k) |
Branch: 3 branches
| Branch | True | False | Total |
| av_push(ys, (k && SvOK(*k) && SvCUR(*k)) ? newSVsv(*k) |
7 |
0 |
7 |
| av_push(ys, (k && SvOK(*k) && SvCUR(*k)) ? newSVsv(*k) |
7 |
0 |
7 |
| av_push(ys, (k && SvOK(*k) && SvCUR(*k)) ? newSVsv(*k) |
7 |
0 |
7 |
|
| 564 |
|
| : newSVpvs("(none)")); |
| 565 |
7 |
| v = hv_fetchs(h, "value", 0); |
| 566 |
7 |
▶ | av_push(xs, povw_num(aTHX_ v ? *v : NULL)); |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(xs, povw_num(aTHX_ v ? *v : NULL)); |
7 |
0 |
7 |
|
| 567 |
|
| } |
| 568 |
|
| |
| 569 |
5 |
| hv_stores(marker, "color", newSVpv(po_plot_role(0), 0)); |
| 570 |
5 |
| hv_stores(trace, "type", newSVpvs("bar")); |
| 571 |
5 |
| hv_stores(trace, "orientation", newSVpvs("h")); |
| 572 |
5 |
| hv_stores(trace, "x", newRV_noinc((SV *)xs)); |
| 573 |
5 |
| hv_stores(trace, "y", newRV_noinc((SV *)ys)); |
| 574 |
5 |
| hv_stores(trace, "marker", newRV_noinc((SV *)marker)); |
| 575 |
5 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 576 |
|
| |
| 577 |
5 |
▶ | hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
0 |
5 |
5 |
| hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
0 |
0 |
0 |
|
| 578 |
|
| : newSVpvs("")); |
| 579 |
5 |
| hv_stores(xaxis, "title", newRV_noinc((SV *)title)); |
| 580 |
5 |
| hv_stores(xaxis, "type", newSVpvs("linear")); |
| 581 |
|
| /* Reversed, so the largest group is at the TOP. A bar chart read from |
| 582 |
|
| * the bottom is a bar chart read wrongly. */ |
| 583 |
5 |
| hv_stores(yaxis, "automargin", newRV_noinc(newSViv(1))); |
| 584 |
5 |
| hv_stores(yaxis, "autorange", newSVpvs("reversed")); |
| 585 |
5 |
| hv_stores(margin, "l", newSViv(140)); |
| 586 |
5 |
| hv_stores(layout, "xaxis", newRV_noinc((SV *)xaxis)); |
| 587 |
5 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 588 |
5 |
| hv_stores(layout, "showlegend", newRV_noinc(newSViv(0))); |
| 589 |
5 |
| hv_stores(layout, "margin", newRV_noinc((SV *)margin)); |
| 590 |
|
| |
| 591 |
5 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
5 |
5 |
|
| 592 |
5 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
5 |
5 |
|
| 593 |
5 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
0 |
5 |
5 |
|
| 594 |
5 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
5 |
5 |
|
| 595 |
5 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
5 |
5 |
|
| 596 |
5 |
| PUTBACK; |
| 597 |
5 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 598 |
5 |
| SPAGAIN; |
| 599 |
5 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
5 |
0 |
5 |
|
| 600 |
5 |
| PUTBACK; |
| 601 |
5 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
5 |
0 |
5 |
|
| 602 |
5 |
| SPAGAIN; |
| 603 |
|
| } |
| 604 |
|
| OUTPUT: |
| 605 |
|
| RETVAL |
| 606 |
|
| |
| 607 |
|
| # One number against a budget. |
| 608 |
|
| # |
| 609 |
|
| # NO DIAL WITHOUT A MAXIMUM. A gauge with no ceiling is a number in a circle, |
| 610 |
|
| # and the circle claims a bound that is not there. |
| 611 |
|
| SV * |
| 612 |
|
| popl_gauge(...) |
| 613 |
|
| CODE: |
| 614 |
|
| { |
| 615 |
9 |
| double value = 0, max = 0, frac; |
| 616 |
9 |
| SV *title = NULL; |
| 617 |
9 |
| HV *trace = newHV(), *layout = newHV(), *margin = newHV(); |
| 618 |
9 |
| HV *tt = newHV(), *number = newHV(), *font = newHV(); |
| 619 |
9 |
| HV *g = newHV(), *axis = newHV(), *bar = newHV(); |
| 620 |
9 |
| AV *range = newAV(), *data = newAV(); |
| 621 |
|
| IV a; |
| 622 |
|
| int got; |
| 623 |
|
| |
| 624 |
36 |
▶ | for (a = 0; a + 1 < items; a += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 0; a + 1 < items; a += 2) { |
27 |
9 |
36 |
|
| 625 |
27 |
| const char *k = SvPV_nolen(ST(a)); |
| 626 |
27 |
▶ | if (strEQ(k, "value")) value = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| if (strEQ(k, "value")) value = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
9 |
18 |
27 |
| if (strEQ(k, "value")) value = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
9 |
0 |
9 |
|
| 627 |
18 |
▶ | else if (strEQ(k, "max")) max = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strEQ(k, "max")) max = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
9 |
9 |
18 |
| else if (strEQ(k, "max")) max = SvOK(ST(a+1)) ? (double)SvNV(ST(a+1)) : 0; |
9 |
0 |
9 |
|
| 628 |
9 |
▶ | else if (strEQ(k, "title")) title = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "title")) title = ST(a + 1); |
9 |
0 |
9 |
|
| 629 |
|
| } |
| 630 |
9 |
▶ | if (!(max > 0)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(max > 0)) { |
8 |
1 |
9 |
|
| 631 |
8 |
| SvREFCNT_dec((SV *)trace); SvREFCNT_dec((SV *)layout); |
| 632 |
8 |
| SvREFCNT_dec((SV *)margin); SvREFCNT_dec((SV *)tt); |
| 633 |
8 |
| SvREFCNT_dec((SV *)number); SvREFCNT_dec((SV *)font); |
| 634 |
8 |
| SvREFCNT_dec((SV *)g); SvREFCNT_dec((SV *)axis); |
| 635 |
8 |
| SvREFCNT_dec((SV *)bar); SvREFCNT_dec((SV *)range); |
| 636 |
8 |
| SvREFCNT_dec((SV *)data); |
| 637 |
8 |
| XSRETURN_UNDEF; |
| 638 |
|
| } |
| 639 |
1 |
| frac = value / max; |
| 640 |
|
| |
| 641 |
1 |
| av_push(range, newSViv(0)); |
| 642 |
1 |
| av_push(range, newSVnv((NV)max)); |
| 643 |
1 |
| hv_stores(axis, "range", newRV_noinc((SV *)range)); |
| 644 |
|
| /* The bar changes colour as it approaches the limit, because the |
| 645 |
|
| * number that matters is how close it is, not what it is. */ |
| 646 |
1 |
▶ | hv_stores(bar, "color", newSVpv(frac >= 0.9 ? "sev:error" |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(bar, "color", newSVpv(frac >= 0.9 ? "sev:error" |
0 |
1 |
1 |
| hv_stores(bar, "color", newSVpv(frac >= 0.9 ? "sev:error" |
0 |
1 |
1 |
|
| 647 |
|
| : frac >= 0.7 ? "sev:warn" |
| 648 |
|
| : po_plot_role(2), 0)); |
| 649 |
1 |
| hv_stores(g, "axis", newRV_noinc((SV *)axis)); |
| 650 |
1 |
| hv_stores(g, "bar", newRV_noinc((SV *)bar)); |
| 651 |
1 |
| hv_stores(g, "borderwidth", newSViv(0)); |
| 652 |
|
| |
| 653 |
1 |
| hv_stores(font, "size", newSViv(20)); |
| 654 |
1 |
| hv_stores(number, "font", newRV_noinc((SV *)font)); |
| 655 |
1 |
▶ | hv_stores(tt, "text", (title && SvOK(title)) ? newSVsv(title) |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(tt, "text", (title && SvOK(title)) ? newSVsv(title) |
1 |
0 |
1 |
| hv_stores(tt, "text", (title && SvOK(title)) ? newSVsv(title) |
1 |
0 |
1 |
|
| 656 |
|
| : newSVpvs("")); |
| 657 |
1 |
| hv_stores(trace, "type", newSVpvs("indicator")); |
| 658 |
1 |
| hv_stores(trace, "mode", newSVpvs("gauge+number")); |
| 659 |
1 |
| hv_stores(trace, "value", newSVnv((NV)value)); |
| 660 |
1 |
| hv_stores(trace, "title", newRV_noinc((SV *)tt)); |
| 661 |
1 |
| hv_stores(trace, "number", newRV_noinc((SV *)number)); |
| 662 |
1 |
| hv_stores(trace, "gauge", newRV_noinc((SV *)g)); |
| 663 |
1 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 664 |
|
| |
| 665 |
1 |
| hv_stores(margin, "l", newSViv(24)); |
| 666 |
1 |
| hv_stores(margin, "r", newSViv(24)); |
| 667 |
1 |
| hv_stores(margin, "t", newSViv(32)); |
| 668 |
1 |
| hv_stores(margin, "b", newSViv(8)); |
| 669 |
1 |
| hv_stores(layout, "margin", newRV_noinc((SV *)margin)); |
| 670 |
1 |
| hv_stores(layout, "height", newSViv(160)); |
| 671 |
|
| /* A gauge has NO AXES, and the way to have none is to not mention |
| 672 |
|
| * them: `xaxis: null` is not a default, it is a failure. _fig drops |
| 673 |
|
| * an undef rather than serialising it. */ |
| 674 |
1 |
| hv_stores(layout, "xaxis", newSV(0)); |
| 675 |
1 |
| hv_stores(layout, "yaxis", newSV(0)); |
| 676 |
|
| |
| 677 |
1 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
1 |
1 |
|
| 678 |
1 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
1 |
1 |
|
| 679 |
1 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
0 |
1 |
1 |
|
| 680 |
1 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
1 |
1 |
|
| 681 |
1 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
1 |
1 |
|
| 682 |
1 |
| PUTBACK; |
| 683 |
1 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 684 |
1 |
| SPAGAIN; |
| 685 |
1 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
1 |
0 |
1 |
|
| 686 |
1 |
| PUTBACK; |
| 687 |
1 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
1 |
0 |
1 |
|
| 688 |
1 |
| SPAGAIN; |
| 689 |
|
| } |
| 690 |
|
| OUTPUT: |
| 691 |
|
| RETVAL |
| 692 |
|
| |
| 693 |
|
| # Log volume, stacked by severity band. |
| 694 |
|
| SV * |
| 695 |
|
| popl_severity_bars(SV *res, ...) |
| 696 |
|
| CODE: |
| 697 |
|
| { |
| 698 |
15 |
| AV *data = newAV(); |
| 699 |
15 |
| HV *r = NULL; |
| 700 |
|
| SV **f; |
| 701 |
15 |
| SV *width = &PL_sv_undef; |
| 702 |
15 |
| SV *unit = NULL; |
| 703 |
15 |
| AV *series = NULL; |
| 704 |
15 |
| SSize_t i, n = 0; |
| 705 |
|
| IV a; |
| 706 |
15 |
| int band, got, role = 0; |
| 707 |
|
| |
| 708 |
30 |
▶ | for (a = 1; a + 1 < items; a += 2) |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) |
15 |
15 |
30 |
|
| 709 |
30 |
▶ | if (strEQ(SvPV_nolen(ST(a)), "unit")) unit = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(SvPV_nolen(ST(a)), "unit")) unit = ST(a + 1); |
15 |
0 |
15 |
|
| 710 |
|
| |
| 711 |
15 |
▶ | if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
15 |
0 |
15 |
| if (SvROK(res) && SvTYPE(SvRV(res)) == SVt_PVHV) r = (HV *)SvRV(res); |
15 |
0 |
15 |
|
| 712 |
15 |
▶ | if (r) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (r) { |
15 |
0 |
15 |
|
| 713 |
15 |
| f = hv_fetchs(r, "bucket_ns", 0); |
| 714 |
15 |
▶ | if (f) width = *f; |
Branch: 1 branch
| Branch | True | False | Total |
| if (f) width = *f; |
15 |
0 |
15 |
|
| 715 |
15 |
| f = hv_fetchs(r, "series", 0); |
| 716 |
15 |
▶ | if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
15 |
0 |
15 |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
15 |
0 |
15 |
| if (f && SvROK(*f) && SvTYPE(SvRV(*f)) == SVt_PVAV) |
15 |
0 |
15 |
|
| 717 |
15 |
| series = (AV *)SvRV(*f); |
| 718 |
|
| } |
| 719 |
15 |
▶ | n = series ? av_len(series) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = series ? av_len(series) + 1 : 0; |
15 |
0 |
15 |
|
| 720 |
|
| |
| 721 |
|
| /* The x and y arrays for one series, through the one implementation |
| 722 |
|
| * of gap filling. */ |
| 723 |
|
| #define POPL_GAPS(sv_pts, xs_out, ys_out) do { \ |
| 724 |
|
| int g_; \ |
| 725 |
|
| ENTER; SAVETMPS; PUSHMARK(SP); \ |
| 726 |
|
| XPUSHs(sv_2mortal((sv_pts) ? newSVsv(sv_pts) \ |
| 727 |
|
| : newRV_noinc((SV *)newAV()))); \ |
| 728 |
|
| XPUSHs(sv_2mortal(newSVsv(width))); \ |
| 729 |
|
| XPUSHs(sv_2mortal(newSViv(1))); \ |
| 730 |
|
| PUTBACK; \ |
| 731 |
|
| g_ = call_pv("Punk::Observe::Plot::_fill_gaps", G_LIST); \ |
| 732 |
|
| SPAGAIN; \ |
| 733 |
|
| if (g_ >= 2) { (ys_out) = SvREFCNT_inc(POPs); \ |
| 734 |
|
| (xs_out) = SvREFCNT_inc(POPs); } \ |
| 735 |
|
| else { (xs_out) = newRV_noinc((SV *)newAV()); \ |
| 736 |
|
| (ys_out) = newRV_noinc((SV *)newAV()); } \ |
| 737 |
|
| PUTBACK; FREETMPS; LEAVE; SPAGAIN; \ |
| 738 |
|
| } while (0) |
| 739 |
|
| |
| 740 |
|
| /* The six bands, in the order a stack wants them: least severe at the |
| 741 |
|
| * bottom, so the eye lands on the top of the stack. */ |
| 742 |
105 |
▶ | for (band = 0; band < 6; band++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (band = 0; band < 6; band++) { |
90 |
15 |
105 |
|
| 743 |
90 |
| const char *want = PO_PLOT_BANDS[band]; |
| 744 |
90 |
| size_t wl = strlen(want); |
| 745 |
222 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
132 |
90 |
222 |
|
| 746 |
132 |
| SV **e = av_fetch(series, i, 0); |
| 747 |
|
| HV *s; |
| 748 |
|
| SV **key, **pts; |
| 749 |
132 |
| SV *xs = NULL, *ys = NULL; |
| 750 |
|
| HV *trace, *marker; |
| 751 |
|
| STRLEN kl; |
| 752 |
|
| const char *kp; |
| 753 |
|
| char role_buf[32]; |
| 754 |
|
| |
| 755 |
242 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
132 |
0 |
132 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
132 |
0 |
132 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
132 |
132 |
|
| 756 |
132 |
| s = (HV *)SvRV(*e); |
| 757 |
132 |
| key = hv_fetchs(s, "key", 0); |
| 758 |
132 |
▶ | if (!key || !SvOK(*key)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!key || !SvOK(*key)) continue; |
132 |
0 |
132 |
| if (!key || !SvOK(*key)) continue; |
0 |
132 |
132 |
|
| 759 |
132 |
| kp = SvPV(*key, kl); |
| 760 |
132 |
▶ | if (kl != wl || memcmp(kp, want, wl) != 0) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (kl != wl || memcmp(kp, want, wl) != 0) continue; |
66 |
66 |
132 |
| if (kl != wl || memcmp(kp, want, wl) != 0) continue; |
44 |
22 |
66 |
|
| 761 |
|
| |
| 762 |
22 |
| pts = hv_fetchs(s, "points", 0); |
| 763 |
22 |
▶ | POPL_GAPS(pts ? *pts : NULL, xs, ys); |
Branch: 9 branches
| Branch | True | False | Total |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
22 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
22 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
22 |
0 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
22 |
0 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
22 |
0 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
22 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
22 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
22 |
0 |
22 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
22 |
0 |
22 |
|
| 764 |
|
| |
| 765 |
22 |
| trace = newHV(); |
| 766 |
22 |
| marker = newHV(); |
| 767 |
22 |
| my_snprintf(role_buf, sizeof(role_buf), "sev:%s", want); |
| 768 |
22 |
| hv_stores(marker, "color", newSVpv(role_buf, 0)); |
| 769 |
22 |
| hv_stores(trace, "type", newSVpvs("bar")); |
| 770 |
22 |
| hv_stores(trace, "name", newSVpvn(want, wl)); |
| 771 |
22 |
| hv_stores(trace, "x", xs); |
| 772 |
22 |
| hv_stores(trace, "y", ys); |
| 773 |
22 |
| hv_stores(trace, "marker", newRV_noinc((SV *)marker)); |
| 774 |
22 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 775 |
|
| } |
| 776 |
|
| } |
| 777 |
|
| |
| 778 |
|
| /* ANYTHING WHOSE LABEL IS NOT ONE OF THE SIX STILL HAS TO APPEAR. A |
| 779 |
|
| * row dropped because its severity was unexpected is a row the |
| 780 |
|
| * operator cannot see, on the screen they opened to find it. */ |
| 781 |
37 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
22 |
15 |
37 |
|
| 782 |
22 |
| SV **e = av_fetch(series, i, 0); |
| 783 |
|
| HV *s, *trace, *marker; |
| 784 |
|
| SV **key, **pts; |
| 785 |
22 |
| SV *xs = NULL, *ys = NULL; |
| 786 |
22 |
| STRLEN kl = 0; |
| 787 |
22 |
| const char *kp = ""; |
| 788 |
22 |
| int known = 0; |
| 789 |
|
| |
| 790 |
44 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
22 |
0 |
22 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
22 |
0 |
22 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
22 |
22 |
|
| 791 |
22 |
| s = (HV *)SvRV(*e); |
| 792 |
22 |
| key = hv_fetchs(s, "key", 0); |
| 793 |
44 |
▶ | if (key && SvOK(*key)) kp = SvPV(*key, kl); |
Branch: 2 branches
| Branch | True | False | Total |
| if (key && SvOK(*key)) kp = SvPV(*key, kl); |
22 |
0 |
22 |
| if (key && SvOK(*key)) kp = SvPV(*key, kl); |
22 |
0 |
22 |
|
| 794 |
88 |
▶ | for (band = 0; band < 6; band++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (band = 0; band < 6; band++) { |
88 |
0 |
88 |
|
| 795 |
88 |
| size_t wl = strlen(PO_PLOT_BANDS[band]); |
| 796 |
88 |
▶ | if (kl == wl && memcmp(kp, PO_PLOT_BANDS[band], wl) == 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (kl == wl && memcmp(kp, PO_PLOT_BANDS[band], wl) == 0) |
44 |
44 |
88 |
| if (kl == wl && memcmp(kp, PO_PLOT_BANDS[band], wl) == 0) |
22 |
22 |
44 |
|
| 797 |
22 |
| { known = 1; break; } |
| 798 |
|
| } |
| 799 |
22 |
▶ | if (known) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (known) continue; |
22 |
0 |
22 |
|
| 800 |
|
| |
| 801 |
0 |
| pts = hv_fetchs(s, "points", 0); |
| 802 |
0 |
▶ | POPL_GAPS(pts ? *pts : NULL, xs, ys); |
Branch: 9 branches
| Branch | True | False | Total |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
| POPL_GAPS(pts ? *pts : NULL, xs, ys); |
0 |
0 |
0 |
|
| 803 |
|
| |
| 804 |
0 |
| trace = newHV(); |
| 805 |
0 |
| marker = newHV(); |
| 806 |
0 |
| hv_stores(marker, "color", newSVpv(po_plot_role(role++), 0)); |
| 807 |
0 |
| hv_stores(trace, "type", newSVpvs("bar")); |
| 808 |
0 |
▶ | hv_stores(trace, "name", kl ? newSVpvn(kp, kl) |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(trace, "name", kl ? newSVpvn(kp, kl) |
0 |
0 |
0 |
|
| 809 |
|
| : newSVpvs("unlabelled")); |
| 810 |
0 |
| hv_stores(trace, "x", xs); |
| 811 |
0 |
| hv_stores(trace, "y", ys); |
| 812 |
0 |
| hv_stores(trace, "marker", newRV_noinc((SV *)marker)); |
| 813 |
0 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 814 |
|
| } |
| 815 |
|
| #undef POPL_GAPS |
| 816 |
|
| |
| 817 |
|
| { |
| 818 |
15 |
| HV *layout = newHV(), *yaxis = newHV(), *title = newHV(); |
| 819 |
15 |
▶ | hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
15 |
0 |
15 |
| hv_stores(title, "text", (unit && SvOK(unit)) ? newSVsv(unit) |
15 |
0 |
15 |
|
| 820 |
|
| : newSVpvs("lines")); |
| 821 |
15 |
| hv_stores(yaxis, "title", newRV_noinc((SV *)title)); |
| 822 |
15 |
| hv_stores(yaxis, "rangemode", newSVpvs("tozero")); |
| 823 |
15 |
| hv_stores(layout, "barmode", newSVpvs("stack")); |
| 824 |
15 |
| hv_stores(layout, "bargap", newSVnv(0.05)); |
| 825 |
15 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 826 |
15 |
| hv_stores(layout, "showlegend", newRV_noinc(newSViv(1))); |
| 827 |
|
| |
| 828 |
15 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
15 |
15 |
|
| 829 |
15 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
15 |
15 |
|
| 830 |
15 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
0 |
15 |
15 |
|
| 831 |
15 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
15 |
15 |
|
| 832 |
15 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
15 |
15 |
|
| 833 |
15 |
| PUTBACK; |
| 834 |
15 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 835 |
15 |
| SPAGAIN; |
| 836 |
15 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
15 |
0 |
15 |
|
| 837 |
15 |
| PUTBACK; |
| 838 |
15 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
15 |
0 |
15 |
|
| 839 |
15 |
| SPAGAIN; |
| 840 |
|
| } |
| 841 |
|
| } |
| 842 |
|
| OUTPUT: |
| 843 |
|
| RETVAL |
| 844 |
|
| |
| 845 |
|
| # WHERE THE SLOW ONES CLUSTER, which a table of the fifty slowest cannot show. |
| 846 |
|
| SV * |
| 847 |
|
| popl_latency_scatter(SV *traces, ...) |
| 848 |
|
| CODE: |
| 849 |
|
| { |
| 850 |
26 |
| AV *data = newAV(); |
| 851 |
26 |
| AV *tr = NULL; |
| 852 |
|
| SSize_t i, n; |
| 853 |
|
| int pass, got; |
| 854 |
|
| |
| 855 |
26 |
▶ | if (SvROK(traces) && SvTYPE(SvRV(traces)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(traces) && SvTYPE(SvRV(traces)) == SVt_PVAV) |
26 |
0 |
26 |
| if (SvROK(traces) && SvTYPE(SvRV(traces)) == SVt_PVAV) |
26 |
0 |
26 |
|
| 856 |
26 |
| tr = (AV *)SvRV(traces); |
| 857 |
26 |
▶ | n = tr ? av_len(tr) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = tr ? av_len(tr) + 1 : 0; |
26 |
0 |
26 |
|
| 858 |
|
| |
| 859 |
|
| /* Two passes, ok then error, so the failing points are drawn on top |
| 860 |
|
| * of the healthy ones rather than under them. */ |
| 861 |
78 |
▶ | for (pass = 0; pass < 2; pass++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (pass = 0; pass < 2; pass++) { |
52 |
26 |
78 |
|
| 862 |
52 |
| AV *xs = newAV(), *ys = newAV(), *cd = newAV(); |
| 863 |
|
| HV *trace, *marker; |
| 864 |
52 |
| int any = 0; |
| 865 |
|
| |
| 866 |
934 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
882 |
52 |
934 |
|
| 867 |
882 |
| SV **e = av_fetch(tr, i, 0); |
| 868 |
|
| HV *t; |
| 869 |
|
| SV **x, **d, **id, **er; |
| 870 |
|
| int bad; |
| 871 |
|
| |
| 872 |
882 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
882 |
0 |
882 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
882 |
0 |
882 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
882 |
882 |
|
| 873 |
882 |
| t = (HV *)SvRV(*e); |
| 874 |
882 |
| er = hv_fetchs(t, "errors", 0); |
| 875 |
882 |
▶ | bad = (er && SvTRUE(*er)) ? 1 : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| bad = (er && SvTRUE(*er)) ? 1 : 0; |
882 |
0 |
882 |
| bad = (er && SvTRUE(*er)) ? 1 : 0; |
32 |
850 |
882 |
|
| 876 |
882 |
▶ | if (bad != pass) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (bad != pass) continue; |
441 |
441 |
882 |
|
| 877 |
|
| |
| 878 |
441 |
| x = hv_fetchs(t, "t", 0); |
| 879 |
|
| { |
| 880 |
441 |
| STRLEN xl = 0; |
| 881 |
882 |
▶ | const char *xp = (x && SvOK(*x)) ? SvPV(*x, xl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *xp = (x && SvOK(*x)) ? SvPV(*x, xl) : ""; |
441 |
0 |
441 |
| const char *xp = (x && SvOK(*x)) ? SvPV(*x, xl) : ""; |
441 |
0 |
441 |
|
| 882 |
441 |
| av_push(xs, po_u64_to_sv(po_plot_ms(xp, (size_t)xl))); |
| 883 |
|
| } |
| 884 |
|
| /* MILLISECONDS, because a latency axis labelled in |
| 885 |
|
| * nanoseconds is a column of digits nobody can compare at a |
| 886 |
|
| * glance. Three digits are dropped as characters and the rest |
| 887 |
|
| * divided, so the value survives a nanosecond duration that a |
| 888 |
|
| * double could not carry whole. */ |
| 889 |
441 |
| d = hv_fetchs(t, "duration", 0); |
| 890 |
|
| { |
| 891 |
441 |
| STRLEN dl = 0; |
| 892 |
882 |
▶ | const char *dp = (d && SvOK(*d)) ? SvPV(*d, dl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *dp = (d && SvOK(*d)) ? SvPV(*d, dl) : ""; |
441 |
0 |
441 |
| const char *dp = (d && SvOK(*d)) ? SvPV(*d, dl) : ""; |
441 |
0 |
441 |
|
| 893 |
441 |
| po_u64 us = 0; |
| 894 |
|
| size_t k; |
| 895 |
1310 |
▶ | if (dl > 3) for (k = 0; k + 3 < dl; k++) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (dl > 3) for (k = 0; k + 3 < dl; k++) { |
441 |
0 |
441 |
| if (dl > 3) for (k = 0; k + 3 < dl; k++) { |
869 |
441 |
1310 |
|
| 896 |
869 |
▶ | if (dp[k] < '0' || dp[k] > '9') { us = 0; break; } |
Branch: 2 branches
| Branch | True | False | Total |
| if (dp[k] < '0' || dp[k] > '9') { us = 0; break; } |
869 |
0 |
869 |
| if (dp[k] < '0' || dp[k] > '9') { us = 0; break; } |
0 |
869 |
869 |
|
| 897 |
869 |
| us = us * 10 + (po_u64)(dp[k] - '0'); |
| 898 |
|
| } |
| 899 |
441 |
| av_push(ys, newSVnv((NV)((double)us / 1000.0))); |
| 900 |
|
| } |
| 901 |
441 |
| id = hv_fetchs(t, "id", 0); |
| 902 |
441 |
▶ | av_push(cd, id ? newSVsv(*id) : newSVpvs("")); |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(cd, id ? newSVsv(*id) : newSVpvs("")); |
441 |
0 |
441 |
|
| 903 |
441 |
| any = 1; |
| 904 |
|
| } |
| 905 |
|
| |
| 906 |
52 |
▶ | if (!any) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!any) { |
11 |
41 |
52 |
|
| 907 |
11 |
| SvREFCNT_dec((SV *)xs); SvREFCNT_dec((SV *)ys); |
| 908 |
11 |
| SvREFCNT_dec((SV *)cd); |
| 909 |
11 |
| continue; |
| 910 |
|
| } |
| 911 |
|
| |
| 912 |
41 |
| trace = newHV(); |
| 913 |
41 |
| marker = newHV(); |
| 914 |
41 |
▶ | hv_stores(marker, "color", newSVpv(pass ? "sev:error" |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(marker, "color", newSVpv(pass ? "sev:error" |
25 |
16 |
41 |
|
| 915 |
|
| : po_plot_role(0), 0)); |
| 916 |
41 |
| hv_stores(marker, "size", newSViv(6)); |
| 917 |
41 |
| hv_stores(marker, "opacity", newSVnv(0.75)); |
| 918 |
41 |
| hv_stores(trace, "type", newSVpvs("scattergl")); |
| 919 |
41 |
| hv_stores(trace, "mode", newSVpvs("markers")); |
| 920 |
41 |
▶ | hv_stores(trace, "name", pass ? newSVpvs("error") : newSVpvs("ok")); |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(trace, "name", pass ? newSVpvs("error") : newSVpvs("ok")); |
16 |
25 |
41 |
|
| 921 |
41 |
| hv_stores(trace, "x", newRV_noinc((SV *)xs)); |
| 922 |
41 |
| hv_stores(trace, "y", newRV_noinc((SV *)ys)); |
| 923 |
41 |
| hv_stores(trace, "customdata", newRV_noinc((SV *)cd)); |
| 924 |
41 |
| hv_stores(trace, "marker", newRV_noinc((SV *)marker)); |
| 925 |
|
| /* The trace id in the hover, which is what plot.js turns into the |
| 926 |
|
| * click: a spike and the trace that caused it are meant to be one |
| 927 |
|
| * gesture apart. */ |
| 928 |
41 |
| hv_stores(trace, "hovertemplate", |
| 929 |
|
| newSVpvs("%{y:.1f} ms<extra>%{customdata}</extra>")); |
| 930 |
41 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 931 |
|
| } |
| 932 |
|
| |
| 933 |
|
| { |
| 934 |
26 |
| HV *layout = newHV(), *yaxis = newHV(), *title = newHV(); |
| 935 |
26 |
| hv_stores(title, "text", newSVpvs("ms")); |
| 936 |
26 |
| hv_stores(yaxis, "title", newRV_noinc((SV *)title)); |
| 937 |
26 |
| hv_stores(yaxis, "rangemode", newSVpvs("tozero")); |
| 938 |
26 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 939 |
26 |
| hv_stores(layout, "showlegend", |
| 940 |
|
| newRV_noinc(newSViv(av_len(data) > 0 ? 1 : 0))); |
| 941 |
26 |
| hv_stores(layout, "hovermode", newSVpvs("closest")); |
| 942 |
|
| |
| 943 |
26 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
26 |
26 |
|
| 944 |
26 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
26 |
26 |
|
| 945 |
26 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
0 |
26 |
26 |
|
| 946 |
26 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
26 |
26 |
|
| 947 |
26 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
26 |
26 |
|
| 948 |
26 |
| PUTBACK; |
| 949 |
26 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 950 |
26 |
| SPAGAIN; |
| 951 |
26 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
26 |
0 |
26 |
|
| 952 |
26 |
| PUTBACK; |
| 953 |
26 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
26 |
0 |
26 |
|
| 954 |
26 |
| SPAGAIN; |
| 955 |
|
| } |
| 956 |
|
| } |
| 957 |
|
| OUTPUT: |
| 958 |
|
| RETVAL |
| 959 |
|
| |
| 960 |
|
| # HOW MUCH, beside what-calls-what. |
| 961 |
|
| # |
| 962 |
|
| # Edge width carries volume on the map, which works for two edges and not for |
| 963 |
|
| # eight: a four-pixel stroke against a six-pixel one does not read as three to |
| 964 |
|
| # two. A flow diagram makes the volume the geometry rather than a hint at it. |
| 965 |
|
| SV * |
| 966 |
|
| popl_service_flow(SV *edges, ...) |
| 967 |
|
| CODE: |
| 968 |
|
| { |
| 969 |
6 |
| AV *e = NULL; |
| 970 |
|
| SSize_t i, n; |
| 971 |
6 |
| AV *label = newAV(), *src = newAV(), *dst = newAV(); |
| 972 |
6 |
| AV *val = newAV(), *col = newAV(), *lab = newAV(); |
| 973 |
6 |
| HV *idx = newHV(); |
| 974 |
|
| IV a; |
| 975 |
6 |
| IV height = 320; |
| 976 |
|
| int got; |
| 977 |
|
| |
| 978 |
6 |
▶ | for (a = 1; a + 1 < items; a += 2) |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) |
0 |
6 |
6 |
|
| 979 |
0 |
▶ | if (strEQ(SvPV_nolen(ST(a)), "height") && SvTRUE(ST(a + 1))) |
Branch: 2 branches
| Branch | True | False | Total |
| if (strEQ(SvPV_nolen(ST(a)), "height") && SvTRUE(ST(a + 1))) |
0 |
0 |
0 |
| if (strEQ(SvPV_nolen(ST(a)), "height") && SvTRUE(ST(a + 1))) |
0 |
0 |
0 |
|
| 980 |
0 |
| height = SvIV(ST(a + 1)); |
| 981 |
|
| |
| 982 |
6 |
▶ | if (SvROK(edges) && SvTYPE(SvRV(edges)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(edges) && SvTYPE(SvRV(edges)) == SVt_PVAV) |
6 |
0 |
6 |
| if (SvROK(edges) && SvTYPE(SvRV(edges)) == SVt_PVAV) |
6 |
0 |
6 |
|
| 983 |
6 |
| e = (AV *)SvRV(edges); |
| 984 |
6 |
▶ | n = e ? av_len(e) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = e ? av_len(e) + 1 : 0; |
6 |
0 |
6 |
|
| 985 |
|
| |
| 986 |
|
| /* Sankey addresses nodes by INDEX, so the labels are collected first |
| 987 |
|
| * and the links refer to positions in that list. */ |
| 988 |
|
| #define POPL_NODE(sv, out) do { \ |
| 989 |
|
| const char *np_ = "internet"; \ |
| 990 |
|
| STRLEN nl_ = 8; \ |
| 991 |
|
| SV **slot_; \ |
| 992 |
|
| if ((sv) && SvOK(*(sv))) { \ |
| 993 |
|
| STRLEN l_; const char *p_ = SvPV(*(sv), l_); \ |
| 994 |
|
| if (!(l_ == 1 && *p_ == '*')) { np_ = p_; nl_ = l_; } \ |
| 995 |
|
| } \ |
| 996 |
|
| slot_ = hv_fetch(idx, np_, (I32)nl_, 0); \ |
| 997 |
|
| if (slot_) (out) = SvIV(*slot_); \ |
| 998 |
|
| else { \ |
| 999 |
|
| (out) = av_len(label) + 1; \ |
| 1000 |
|
| av_push(label, newSVpvn(np_, nl_)); \ |
| 1001 |
|
| (void)hv_store(idx, np_, (I32)nl_, newSViv(out), 0); \ |
| 1002 |
|
| } \ |
| 1003 |
|
| } while (0) |
| 1004 |
|
| |
| 1005 |
17 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
11 |
6 |
17 |
|
| 1006 |
11 |
| SV **el = av_fetch(e, i, 0); |
| 1007 |
|
| HV *h; |
| 1008 |
|
| SV **back, **cnt, **er; |
| 1009 |
11 |
| po_u64 count = 0; |
| 1010 |
|
| IV s_i, d_i; |
| 1011 |
|
| |
| 1012 |
11 |
▶ | if (!el || !SvROK(*el) || SvTYPE(SvRV(*el)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!el || !SvROK(*el) || SvTYPE(SvRV(*el)) != SVt_PVHV) continue; |
11 |
0 |
11 |
| if (!el || !SvROK(*el) || SvTYPE(SvRV(*el)) != SVt_PVHV) continue; |
11 |
0 |
11 |
| if (!el || !SvROK(*el) || SvTYPE(SvRV(*el)) != SVt_PVHV) continue; |
0 |
11 |
11 |
|
| 1013 |
11 |
| h = (HV *)SvRV(*el); |
| 1014 |
|
| |
| 1015 |
|
| /* A BACK EDGE IS DROPPED, NOT DRAWN. A Sankey lays nodes out left |
| 1016 |
|
| * to right by following the flow; an edge that returns has no |
| 1017 |
|
| * position in that order and the layout either loops forever or |
| 1018 |
|
| * draws nonsense. The map beside this one shows them dashed, |
| 1019 |
|
| * which is where a cycle belongs. */ |
| 1020 |
11 |
| back = hv_fetchs(h, "back", 0); |
| 1021 |
11 |
▶ | if (back && SvTRUE(*back)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (back && SvTRUE(*back)) continue; |
10 |
1 |
11 |
| if (back && SvTRUE(*back)) continue; |
0 |
10 |
10 |
|
| 1022 |
|
| |
| 1023 |
11 |
| cnt = hv_fetchs(h, "count", 0); |
| 1024 |
11 |
▶ | if (cnt) (void)po_sv_to_u64(aTHX_ *cnt, &count); |
Branch: 1 branch
| Branch | True | False | Total |
| if (cnt) (void)po_sv_to_u64(aTHX_ *cnt, &count); |
11 |
0 |
11 |
|
| 1025 |
11 |
▶ | if (!count) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!count) continue; |
0 |
11 |
11 |
|
| 1026 |
|
| |
| 1027 |
33 |
▶ | POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
Branch: 5 branches
| Branch | True | False | Total |
| POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
11 |
0 |
11 |
| POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
11 |
0 |
11 |
| POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
1 |
10 |
11 |
| POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
1 |
0 |
1 |
| POPL_NODE(hv_fetchs(h, "caller", 0), s_i); |
5 |
6 |
11 |
|
| 1028 |
33 |
▶ | POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
Branch: 5 branches
| Branch | True | False | Total |
| POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
11 |
0 |
11 |
| POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
11 |
0 |
11 |
| POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
1 |
10 |
11 |
| POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
1 |
0 |
1 |
| POPL_NODE(hv_fetchs(h, "callee", 0), d_i); |
0 |
11 |
11 |
|
| 1029 |
11 |
| av_push(src, newSViv(s_i)); |
| 1030 |
11 |
| av_push(dst, newSViv(d_i)); |
| 1031 |
11 |
| av_push(val, po_u64_to_sv(count)); |
| 1032 |
|
| |
| 1033 |
|
| /* A failing edge is coloured by its FAILURE, because the question |
| 1034 |
|
| * asked of this diagram during an incident is which flow is red. */ |
| 1035 |
11 |
| er = hv_fetchs(h, "errors", 0); |
| 1036 |
11 |
▶ | av_push(col, (er && SvTRUE(*er)) ? newSVpvs("sev:error") |
Branch: 2 branches
| Branch | True | False | Total |
| av_push(col, (er && SvTRUE(*er)) ? newSVpvs("sev:error") |
11 |
0 |
11 |
| av_push(col, (er && SvTRUE(*er)) ? newSVpvs("sev:error") |
5 |
6 |
11 |
|
| 1037 |
|
| : newSVpvs("series:0")); |
| 1038 |
|
| { |
| 1039 |
11 |
| SV *l = po_u64_to_sv(count); |
| 1040 |
11 |
| sv_catpvs(l, " calls"); |
| 1041 |
11 |
▶ | if (er && SvTRUE(*er)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (er && SvTRUE(*er)) { |
11 |
0 |
11 |
| if (er && SvTRUE(*er)) { |
5 |
6 |
11 |
|
| 1042 |
5 |
| sv_catpvs(l, ", "); |
| 1043 |
5 |
| sv_catsv(l, *er); |
| 1044 |
5 |
| sv_catpvs(l, " in error"); |
| 1045 |
|
| } |
| 1046 |
11 |
| av_push(lab, l); |
| 1047 |
|
| } |
| 1048 |
|
| } |
| 1049 |
|
| #undef POPL_NODE |
| 1050 |
|
| |
| 1051 |
6 |
▶ | if (av_len(src) < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(src) < 0) { |
0 |
6 |
6 |
|
| 1052 |
0 |
| SvREFCNT_dec((SV *)label); SvREFCNT_dec((SV *)src); |
| 1053 |
0 |
| SvREFCNT_dec((SV *)dst); SvREFCNT_dec((SV *)val); |
| 1054 |
0 |
| SvREFCNT_dec((SV *)col); SvREFCNT_dec((SV *)lab); |
| 1055 |
0 |
| SvREFCNT_dec((SV *)idx); |
| 1056 |
0 |
| XSRETURN_UNDEF; |
| 1057 |
|
| } |
| 1058 |
|
| |
| 1059 |
|
| { |
| 1060 |
6 |
| HV *trace = newHV(), *node = newHV(), *link = newHV(), *line = newHV(); |
| 1061 |
6 |
| HV *layout = newHV(); |
| 1062 |
6 |
| AV *data = newAV(); |
| 1063 |
|
| |
| 1064 |
6 |
| hv_stores(line, "color", newSVpvs("line")); |
| 1065 |
6 |
| hv_stores(line, "width", newSViv(1)); |
| 1066 |
6 |
| hv_stores(node, "label", newRV_noinc((SV *)label)); |
| 1067 |
6 |
| hv_stores(node, "pad", newSViv(14)); |
| 1068 |
6 |
| hv_stores(node, "thickness", newSViv(14)); |
| 1069 |
6 |
| hv_stores(node, "color", newSVpvs("series:2")); |
| 1070 |
6 |
| hv_stores(node, "line", newRV_noinc((SV *)line)); |
| 1071 |
|
| |
| 1072 |
6 |
| hv_stores(link, "source", newRV_noinc((SV *)src)); |
| 1073 |
6 |
| hv_stores(link, "target", newRV_noinc((SV *)dst)); |
| 1074 |
6 |
| hv_stores(link, "value", newRV_noinc((SV *)val)); |
| 1075 |
6 |
| hv_stores(link, "color", newRV_noinc((SV *)col)); |
| 1076 |
6 |
| hv_stores(link, "label", newRV_noinc((SV *)lab)); |
| 1077 |
|
| |
| 1078 |
6 |
| hv_stores(trace, "type", newSVpvs("sankey")); |
| 1079 |
6 |
| hv_stores(trace, "orientation", newSVpvs("h")); |
| 1080 |
6 |
| hv_stores(trace, "node", newRV_noinc((SV *)node)); |
| 1081 |
6 |
| hv_stores(trace, "link", newRV_noinc((SV *)link)); |
| 1082 |
6 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 1083 |
|
| |
| 1084 |
|
| /* A Sankey has NO AXES, and the shared date x-axis would draw |
| 1085 |
|
| * one. _fig drops an undef rather than serialising a null. */ |
| 1086 |
6 |
| hv_stores(layout, "xaxis", newSV(0)); |
| 1087 |
6 |
| hv_stores(layout, "yaxis", newSV(0)); |
| 1088 |
6 |
| hv_stores(layout, "hovermode", newSVpvs("closest")); |
| 1089 |
6 |
| hv_stores(layout, "showlegend", newRV_noinc(newSViv(0))); |
| 1090 |
6 |
| hv_stores(layout, "height", newSViv(height)); |
| 1091 |
|
| |
| 1092 |
6 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
6 |
6 |
|
| 1093 |
6 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
6 |
6 |
|
| 1094 |
6 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)data))); |
0 |
6 |
6 |
|
| 1095 |
6 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
6 |
6 |
|
| 1096 |
6 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
6 |
6 |
|
| 1097 |
6 |
| PUTBACK; |
| 1098 |
6 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 1099 |
6 |
| SPAGAIN; |
| 1100 |
6 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
6 |
0 |
6 |
|
| 1101 |
6 |
| PUTBACK; |
| 1102 |
6 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
6 |
0 |
6 |
|
| 1103 |
6 |
| SPAGAIN; |
| 1104 |
|
| } |
| 1105 |
6 |
| SvREFCNT_dec((SV *)idx); |
| 1106 |
|
| } |
| 1107 |
|
| OUTPUT: |
| 1108 |
|
| RETVAL |
| 1109 |
|
| |
| 1110 |
|
| # Transitions into bands. |
| 1111 |
|
| # |
| 1112 |
|
| # ONE BAND RUNS TO THE NEXT TRANSITION of the same series, not to a fixed |
| 1113 |
|
| # width. The interval is the whole information content: two bands of equal |
| 1114 |
|
| # width would say a four-minute outage and a five-hour one were the same |
| 1115 |
|
| # event. |
| 1116 |
|
| SV * |
| 1117 |
|
| popl_alert_timeline(SV *events, ...) |
| 1118 |
|
| CODE: |
| 1119 |
|
| { |
| 1120 |
6 |
| AV *ev = NULL; |
| 1121 |
6 |
| SV *to = NULL; |
| 1122 |
|
| IV a; |
| 1123 |
6 |
| SSize_t i, n, nseries = 0; |
| 1124 |
6 |
| HV *by = newHV(); |
| 1125 |
6 |
| HV *seen = newHV(); |
| 1126 |
6 |
| AV *data = newAV(); |
| 1127 |
6 |
| AV *names = newAV(); |
| 1128 |
6 |
| SV *end = NULL; |
| 1129 |
|
| int got; |
| 1130 |
|
| |
| 1131 |
9 |
▶ | for (a = 1; a + 1 < items; a += 2) |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) |
3 |
6 |
9 |
|
| 1132 |
6 |
▶ | if (strEQ(SvPV_nolen(ST(a)), "to")) to = ST(a + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(SvPV_nolen(ST(a)), "to")) to = ST(a + 1); |
3 |
0 |
3 |
|
| 1133 |
|
| |
| 1134 |
|
| /* The seam's whole answer is accepted as well as its events list, so |
| 1135 |
|
| * a caller in C hands over one scalar rather than digging a key out |
| 1136 |
|
| * first. */ |
| 1137 |
9 |
▶ | if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVHV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVHV) { |
6 |
0 |
6 |
| if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVHV) { |
3 |
3 |
6 |
|
| 1138 |
3 |
| HV *h = (HV *)SvRV(events); |
| 1139 |
3 |
| SV **t = hv_fetchs(h, "to", 0); |
| 1140 |
3 |
| SV **e = hv_fetchs(h, "events", 0); |
| 1141 |
3 |
▶ | if (t && SvOK(*t)) to = *t; |
Branch: 2 branches
| Branch | True | False | Total |
| if (t && SvOK(*t)) to = *t; |
0 |
3 |
3 |
| if (t && SvOK(*t)) to = *t; |
0 |
0 |
0 |
|
| 1142 |
3 |
▶ | if (e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVAV) |
0 |
3 |
3 |
| if (e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVAV) |
0 |
0 |
0 |
| if (e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVAV) |
0 |
0 |
0 |
|
| 1143 |
0 |
| ev = (AV *)SvRV(*e); |
| 1144 |
|
| } |
| 1145 |
3 |
▶ | else if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVAV) |
3 |
0 |
3 |
| else if (SvROK(events) && SvTYPE(SvRV(events)) == SVt_PVAV) |
3 |
0 |
3 |
|
| 1146 |
3 |
| ev = (AV *)SvRV(events); |
| 1147 |
|
| |
| 1148 |
6 |
▶ | n = ev ? av_len(ev) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = ev ? av_len(ev) + 1 : 0; |
3 |
3 |
6 |
|
| 1149 |
6 |
▶ | if (!n) goto nothing; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!n) goto nothing; |
4 |
2 |
6 |
|
| 1150 |
|
| |
| 1151 |
7 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
5 |
2 |
7 |
|
| 1152 |
5 |
| SV **e = av_fetch(ev, i, 0); |
| 1153 |
|
| HV *h; |
| 1154 |
|
| SV **s, **at; |
| 1155 |
|
| STRLEN sl; |
| 1156 |
|
| const char *sp; |
| 1157 |
|
| SV **slot; |
| 1158 |
|
| |
| 1159 |
5 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
5 |
0 |
5 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
5 |
0 |
5 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
5 |
5 |
|
| 1160 |
5 |
| h = (HV *)SvRV(*e); |
| 1161 |
5 |
| s = hv_fetchs(h, "series", 0); |
| 1162 |
5 |
| at = hv_fetchs(h, "at", 0); |
| 1163 |
5 |
▶ | if (!s || !SvOK(*s) || !at || !SvOK(*at)) continue; |
Branch: 4 branches
| Branch | True | False | Total |
| if (!s || !SvOK(*s) || !at || !SvOK(*at)) continue; |
5 |
0 |
5 |
| if (!s || !SvOK(*s) || !at || !SvOK(*at)) continue; |
5 |
0 |
5 |
| if (!s || !SvOK(*s) || !at || !SvOK(*at)) continue; |
5 |
0 |
5 |
| if (!s || !SvOK(*s) || !at || !SvOK(*at)) continue; |
0 |
5 |
5 |
|
| 1164 |
5 |
| sp = SvPV(*s, sl); |
| 1165 |
5 |
| slot = hv_fetch(by, sp, (I32)sl, 1); |
| 1166 |
5 |
▶ | if (!slot) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!slot) continue; |
0 |
5 |
5 |
|
| 1167 |
5 |
▶ | if (!SvROK(*slot)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvROK(*slot)) { |
3 |
2 |
5 |
|
| 1168 |
3 |
| sv_setsv(*slot, sv_2mortal(newRV_noinc((SV *)newAV()))); |
| 1169 |
3 |
| av_push(names, newSVpvn(sp, sl)); |
| 1170 |
3 |
| nseries++; |
| 1171 |
|
| } |
| 1172 |
5 |
| av_push((AV *)SvRV(*slot), SvREFCNT_inc(*e)); |
| 1173 |
|
| } |
| 1174 |
2 |
▶ | if (!nseries) goto nothing; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!nseries) goto nothing; |
0 |
2 |
2 |
|
| 1175 |
|
| |
| 1176 |
|
| /* THE RIGHT EDGE IS NOW, and that is not a fallback - it is what the |
| 1177 |
|
| * last band means. A state that has not been left yet is still in |
| 1178 |
|
| * force, so its band runs to the present moment; ending it at the |
| 1179 |
|
| * last transition would draw an ongoing incident as an instant that |
| 1180 |
|
| * finished when it started. */ |
| 1181 |
2 |
▶ | if (to && SvOK(to)) end = newSVsv(to); |
Branch: 2 branches
| Branch | True | False | Total |
| if (to && SvOK(to)) end = newSVsv(to); |
2 |
0 |
2 |
| if (to && SvOK(to)) end = newSVsv(to); |
2 |
0 |
2 |
|
| 1182 |
|
| else { |
| 1183 |
0 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
0 |
0 |
|
| 1184 |
0 |
| PUTBACK; |
| 1185 |
0 |
| got = call_pv("Punk::Observe::now_ns", G_SCALAR); |
| 1186 |
0 |
| SPAGAIN; |
| 1187 |
0 |
▶ | end = got ? newSVsv(POPs) : newSVpvs("0"); |
Branch: 1 branch
| Branch | True | False | Total |
| end = got ? newSVsv(POPs) : newSVpvs("0"); |
0 |
0 |
0 |
|
| 1188 |
0 |
| PUTBACK; |
| 1189 |
0 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
0 |
0 |
0 |
|
| 1190 |
0 |
| SPAGAIN; |
| 1191 |
|
| } |
| 1192 |
|
| |
| 1193 |
|
| /* The series in name order, so two renders of the same history put |
| 1194 |
|
| * the rows in the same places. */ |
| 1195 |
2 |
| sortsv(AvARRAY(names), (SSize_t)(av_len(names) + 1), Perl_sv_cmp); |
| 1196 |
|
| |
| 1197 |
5 |
▶ | for (i = 0; i <= av_len(names); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(names); i++) { |
3 |
2 |
5 |
|
| 1198 |
3 |
| SV **nm = av_fetch(names, i, 0); |
| 1199 |
|
| STRLEN sl; |
| 1200 |
|
| const char *sp; |
| 1201 |
|
| SV **slot; |
| 1202 |
|
| AV *list; |
| 1203 |
|
| SSize_t j, cnt; |
| 1204 |
|
| |
| 1205 |
3 |
▶ | if (!nm) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!nm) continue; |
0 |
3 |
3 |
|
| 1206 |
3 |
| sp = SvPV(*nm, sl); |
| 1207 |
3 |
| slot = hv_fetch(by, sp, (I32)sl, 0); |
| 1208 |
3 |
▶ | if (!slot || !SvROK(*slot)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!slot || !SvROK(*slot)) continue; |
3 |
0 |
3 |
| if (!slot || !SvROK(*slot)) continue; |
0 |
3 |
3 |
|
| 1209 |
3 |
| list = (AV *)SvRV(*slot); |
| 1210 |
3 |
| cnt = av_len(list) + 1; |
| 1211 |
|
| |
| 1212 |
|
| /* By instant. Compared as decimal STRINGS by width then value: |
| 1213 |
|
| * a nanosecond instant past 2^53 does not survive being made a |
| 1214 |
|
| * number, and two transitions a microsecond apart would then sort |
| 1215 |
|
| * as equal. */ |
| 1216 |
|
| { |
| 1217 |
3 |
| SV **arr = AvARRAY(list); |
| 1218 |
|
| SSize_t x; |
| 1219 |
5 |
▶ | for (x = 1; x < cnt; x++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (x = 1; x < cnt; x++) { |
2 |
3 |
5 |
|
| 1220 |
2 |
| SV *k = arr[x]; |
| 1221 |
2 |
| SV **ka = hv_fetchs((HV *)SvRV(k), "at", 0); |
| 1222 |
2 |
| STRLEN kl = 0; |
| 1223 |
4 |
▶ | const char *kp = (ka && SvOK(*ka)) ? SvPV(*ka, kl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *kp = (ka && SvOK(*ka)) ? SvPV(*ka, kl) : ""; |
2 |
0 |
2 |
| const char *kp = (ka && SvOK(*ka)) ? SvPV(*ka, kl) : ""; |
2 |
0 |
2 |
|
| 1224 |
|
| SSize_t y; |
| 1225 |
2 |
▶ | for (y = x - 1; y >= 0; y--) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (y = x - 1; y >= 0; y--) { |
2 |
0 |
2 |
|
| 1226 |
2 |
| SV **ja = hv_fetchs((HV *)SvRV(arr[y]), "at", 0); |
| 1227 |
2 |
| STRLEN jl = 0; |
| 1228 |
4 |
▶ | const char *jp = (ja && SvOK(*ja)) ? SvPV(*ja, jl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *jp = (ja && SvOK(*ja)) ? SvPV(*ja, jl) : ""; |
2 |
0 |
2 |
| const char *jp = (ja && SvOK(*ja)) ? SvPV(*ja, jl) : ""; |
2 |
0 |
2 |
|
| 1229 |
2 |
▶ | if (po_ns_cmp_str(jp, (size_t)jl, kp, (size_t)kl, NULL) <= 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (po_ns_cmp_str(jp, (size_t)jl, kp, (size_t)kl, NULL) <= 0) |
2 |
0 |
2 |
|
| 1230 |
2 |
| break; |
| 1231 |
0 |
| arr[y + 1] = arr[y]; |
| 1232 |
|
| } |
| 1233 |
2 |
| arr[y + 1] = k; |
| 1234 |
|
| } |
| 1235 |
|
| } |
| 1236 |
|
| |
| 1237 |
8 |
▶ | for (j = 0; j < cnt; j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < cnt; j++) { |
5 |
3 |
8 |
|
| 1238 |
5 |
| SV **e = av_fetch(list, j, 0); |
| 1239 |
|
| HV *h, *trace, *marker; |
| 1240 |
|
| SV **st, **at; |
| 1241 |
5 |
| const char *state = "ok"; |
| 1242 |
5 |
| STRLEN stl = 2; |
| 1243 |
|
| po_u64 start_ms, stop_ms; |
| 1244 |
|
| double width; |
| 1245 |
5 |
| AV *base = newAV(), *xs = newAV(), *ys = newAV(); |
| 1246 |
|
| SV *hov; |
| 1247 |
|
| SV **fs; |
| 1248 |
|
| |
| 1249 |
5 |
▶ | if (!e || !SvROK(*e)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e)) continue; |
5 |
0 |
5 |
| if (!e || !SvROK(*e)) continue; |
0 |
5 |
5 |
|
| 1250 |
5 |
| h = (HV *)SvRV(*e); |
| 1251 |
5 |
| st = hv_fetchs(h, "to", 0); |
| 1252 |
10 |
▶ | if (st && SvOK(*st) && SvCUR(*st)) state = SvPV(*st, stl); |
Branch: 3 branches
| Branch | True | False | Total |
| if (st && SvOK(*st) && SvCUR(*st)) state = SvPV(*st, stl); |
5 |
0 |
5 |
| if (st && SvOK(*st) && SvCUR(*st)) state = SvPV(*st, stl); |
5 |
0 |
5 |
| if (st && SvOK(*st) && SvCUR(*st)) state = SvPV(*st, stl); |
5 |
0 |
5 |
|
| 1253 |
5 |
| at = hv_fetchs(h, "at", 0); |
| 1254 |
|
| |
| 1255 |
|
| { |
| 1256 |
5 |
| STRLEN al = 0; |
| 1257 |
10 |
▶ | const char *ap = (at && SvOK(*at)) ? SvPV(*at, al) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *ap = (at && SvOK(*at)) ? SvPV(*at, al) : ""; |
5 |
0 |
5 |
| const char *ap = (at && SvOK(*at)) ? SvPV(*at, al) : ""; |
5 |
0 |
5 |
|
| 1258 |
5 |
| start_ms = po_plot_ms(ap, (size_t)al); |
| 1259 |
|
| } |
| 1260 |
|
| { |
| 1261 |
5 |
| SV *stop = NULL; |
| 1262 |
5 |
| STRLEN pl = 0; |
| 1263 |
|
| const char *pp; |
| 1264 |
5 |
▶ | if (j + 1 < cnt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (j + 1 < cnt) { |
2 |
3 |
5 |
|
| 1265 |
2 |
| SV **nx = av_fetch(list, j + 1, 0); |
| 1266 |
2 |
▶ | SV **na = (nx && SvROK(*nx)) |
Branch: 1 branch
| Branch | True | False | Total |
| SV **na = (nx && SvROK(*nx)) |
2 |
0 |
2 |
|
| 1267 |
4 |
▶ | ? hv_fetchs((HV *)SvRV(*nx), "at", 0) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? hv_fetchs((HV *)SvRV(*nx), "at", 0) : NULL; |
2 |
0 |
2 |
|
| 1268 |
2 |
▶ | stop = (na && SvOK(*na)) ? *na : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| stop = (na && SvOK(*na)) ? *na : NULL; |
2 |
0 |
2 |
| stop = (na && SvOK(*na)) ? *na : NULL; |
2 |
0 |
2 |
|
| 1269 |
|
| } |
| 1270 |
3 |
| else stop = end; |
| 1271 |
5 |
▶ | if (!stop || !SvOK(stop)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!stop || !SvOK(stop)) { |
5 |
0 |
5 |
| if (!stop || !SvOK(stop)) { |
0 |
5 |
5 |
|
| 1272 |
0 |
| SvREFCNT_dec((SV *)base); SvREFCNT_dec((SV *)xs); |
| 1273 |
0 |
| SvREFCNT_dec((SV *)ys); |
| 1274 |
0 |
| continue; |
| 1275 |
|
| } |
| 1276 |
5 |
| pp = SvPV(stop, pl); |
| 1277 |
5 |
| stop_ms = po_plot_ms(pp, (size_t)pl); |
| 1278 |
|
| } |
| 1279 |
|
| |
| 1280 |
5 |
| width = (double)stop_ms - (double)start_ms; |
| 1281 |
|
| /* A transition and the next in the same millisecond would be |
| 1282 |
|
| * a bar of zero width, which draws as nothing at all - so it |
| 1283 |
|
| * gets the minimum that is still visible. */ |
| 1284 |
5 |
▶ | if (width < 1) width = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if (width < 1) width = 1; |
0 |
5 |
5 |
|
| 1285 |
|
| |
| 1286 |
5 |
| av_push(base, po_u64_to_sv(start_ms)); |
| 1287 |
5 |
| av_push(xs, povw_num(aTHX_ sv_2mortal(newSVnv((NV)width)))); |
| 1288 |
5 |
| av_push(ys, newSVpvn(sp, sl)); |
| 1289 |
|
| |
| 1290 |
5 |
| trace = newHV(); |
| 1291 |
5 |
| marker = newHV(); |
| 1292 |
|
| /* `up` and `down` are HEALTH's words, and they are here so |
| 1293 |
|
| * that page can use its own vocabulary rather than borrow an |
| 1294 |
|
| * alert's: a legend reading "firing" over a service-uptime |
| 1295 |
|
| * band would be describing a rule that does not exist. Same |
| 1296 |
|
| * two colours, because the reading is the same one. */ |
| 1297 |
5 |
▶ | hv_stores(marker, "color", |
Branch: 7 branches
| Branch | True | False | Total |
| hv_stores(marker, "color", |
4 |
1 |
5 |
| hv_stores(marker, "color", |
4 |
0 |
4 |
| hv_stores(marker, "color", |
3 |
1 |
4 |
| hv_stores(marker, "color", |
0 |
3 |
3 |
| hv_stores(marker, "color", |
0 |
0 |
0 |
| hv_stores(marker, "color", |
0 |
0 |
0 |
| hv_stores(marker, "color", |
0 |
0 |
0 |
|
| 1298 |
|
| newSVpv(strEQ(state, "ok") ? "ok" |
| 1299 |
|
| : strEQ(state, "up") ? "ok" |
| 1300 |
|
| : strEQ(state, "pending") ? "warn" |
| 1301 |
|
| : strEQ(state, "firing") ? "err" |
| 1302 |
|
| : strEQ(state, "down") ? "err" |
| 1303 |
|
| : strEQ(state, "stale") ? "muted" |
| 1304 |
|
| : strEQ(state, "error") ? "warn" |
| 1305 |
|
| : "muted", 0)); |
| 1306 |
5 |
| hv_stores(trace, "type", newSVpvs("bar")); |
| 1307 |
5 |
| hv_stores(trace, "orientation", newSVpvs("h")); |
| 1308 |
5 |
| hv_stores(trace, "base", newRV_noinc((SV *)base)); |
| 1309 |
5 |
| hv_stores(trace, "x", newRV_noinc((SV *)xs)); |
| 1310 |
5 |
| hv_stores(trace, "y", newRV_noinc((SV *)ys)); |
| 1311 |
5 |
| hv_stores(trace, "name", newSVpvn(state, stl)); |
| 1312 |
|
| /* ONE LEGEND ENTRY PER STATE rather than per band, or a rule |
| 1313 |
|
| * that flapped twelve times gets twelve identical rows. */ |
| 1314 |
5 |
| fs = hv_fetch(seen, state, (I32)stl, 1); |
| 1315 |
5 |
▶ | hv_stores(trace, "showlegend", |
Branch: 2 branches
| Branch | True | False | Total |
| hv_stores(trace, "showlegend", |
5 |
0 |
5 |
| hv_stores(trace, "showlegend", |
4 |
1 |
5 |
|
| 1316 |
|
| newRV_noinc(newSViv((fs && SvTRUE(*fs)) ? 0 : 1))); |
| 1317 |
5 |
▶ | if (fs) sv_setiv(*fs, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (fs) sv_setiv(*fs, 1); |
5 |
0 |
5 |
|
| 1318 |
5 |
| hv_stores(trace, "legendgroup", newSVpvn(state, stl)); |
| 1319 |
5 |
| hv_stores(trace, "marker", newRV_noinc((SV *)marker)); |
| 1320 |
5 |
| hov = newSVpvn(sp, sl); |
| 1321 |
5 |
| sv_catpvs(hov, ": "); |
| 1322 |
5 |
| sv_catpvn(hov, state, stl); |
| 1323 |
5 |
| sv_catpvs(hov, "<extra></extra>"); |
| 1324 |
5 |
| hv_stores(trace, "hovertemplate", hov); |
| 1325 |
5 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 1326 |
|
| } |
| 1327 |
|
| } |
| 1328 |
|
| |
| 1329 |
2 |
▶ | if (av_len(data) < 0) goto nothing; |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(data) < 0) goto nothing; |
0 |
2 |
2 |
|
| 1330 |
|
| |
| 1331 |
|
| { |
| 1332 |
2 |
| HV *layout = newHV(), *xaxis = newHV(), *yaxis = newHV(); |
| 1333 |
2 |
| hv_stores(xaxis, "type", newSVpvs("date")); |
| 1334 |
2 |
| hv_stores(yaxis, "automargin", newRV_noinc(newSViv(1))); |
| 1335 |
2 |
| hv_stores(yaxis, "type", newSVpvs("category")); |
| 1336 |
|
| /* Overlay, not stack: the bands of one series are consecutive in |
| 1337 |
|
| * time, and stacking would add their widths together. */ |
| 1338 |
2 |
| hv_stores(layout, "barmode", newSVpvs("overlay")); |
| 1339 |
2 |
| hv_stores(layout, "xaxis", newRV_noinc((SV *)xaxis)); |
| 1340 |
2 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 1341 |
2 |
| hv_stores(layout, "height", newSViv(120 + 22 * (IV)nseries)); |
| 1342 |
2 |
| hv_stores(layout, "showlegend", newRV_noinc(newSViv(1))); |
| 1343 |
|
| |
| 1344 |
2 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
2 |
2 |
|
| 1345 |
2 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
2 |
2 |
|
| 1346 |
2 |
▶ | XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
0 |
2 |
2 |
|
| 1347 |
2 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
2 |
2 |
|
| 1348 |
2 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
2 |
2 |
|
| 1349 |
2 |
| PUTBACK; |
| 1350 |
2 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 1351 |
2 |
| SPAGAIN; |
| 1352 |
2 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newRV_noinc((SV *)newHV()); |
2 |
0 |
2 |
|
| 1353 |
2 |
| PUTBACK; |
| 1354 |
2 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
2 |
0 |
2 |
|
| 1355 |
2 |
| SPAGAIN; |
| 1356 |
|
| } |
| 1357 |
2 |
| goto cleanup; |
| 1358 |
|
| |
| 1359 |
|
| /* NO TRANSITIONS MEANS NO CHART, not an empty one. An empty panel |
| 1360 |
|
| * reads as "nothing has happened", which is a different and unearned |
| 1361 |
|
| * claim. */ |
| 1362 |
4 |
| nothing: |
| 1363 |
4 |
| RETVAL = &PL_sv_undef; |
| 1364 |
4 |
| SvREFCNT_inc(RETVAL); |
| 1365 |
6 |
| cleanup: |
| 1366 |
6 |
▶ | if (end) SvREFCNT_dec(end); |
Branch: 1 branch
| Branch | True | False | Total |
| if (end) SvREFCNT_dec(end); |
2 |
4 |
6 |
|
| 1367 |
6 |
| SvREFCNT_dec((SV *)by); |
| 1368 |
6 |
| SvREFCNT_dec((SV *)seen); |
| 1369 |
6 |
| SvREFCNT_dec((SV *)names); |
| 1370 |
6 |
| SvREFCNT_dec((SV *)data); |
| 1371 |
|
| } |
| 1372 |
|
| OUTPUT: |
| 1373 |
|
| RETVAL |
| 1374 |
|
| |
| 1375 |
|
| SV * |
| 1376 |
|
| popl_timeline_figure(SV *events) |
| 1377 |
|
| CODE: |
| 1378 |
|
| { |
| 1379 |
2 |
| SV *fig = NULL, *enc = NULL; |
| 1380 |
|
| int got; |
| 1381 |
|
| |
| 1382 |
2 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
2 |
2 |
|
| 1383 |
2 |
▶ | XPUSHs(events); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(events); |
0 |
2 |
2 |
|
| 1384 |
2 |
| PUTBACK; |
| 1385 |
2 |
| got = call_pv("Punk::Observe::Plot::alert_timeline", G_SCALAR); |
| 1386 |
2 |
| SPAGAIN; |
| 1387 |
2 |
▶ | fig = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| fig = got ? SvREFCNT_inc(POPs) : NULL; |
2 |
0 |
2 |
|
| 1388 |
2 |
| PUTBACK; |
| 1389 |
2 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
0 |
2 |
2 |
|
| 1390 |
2 |
| SPAGAIN; |
| 1391 |
|
| |
| 1392 |
2 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
2 |
2 |
|
| 1393 |
2 |
▶ | XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
0 |
2 |
2 |
| XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
2 |
0 |
2 |
|
| 1394 |
2 |
| PUTBACK; |
| 1395 |
2 |
| got = call_pv("Punk::Observe::Plot::encode", G_SCALAR); |
| 1396 |
2 |
| SPAGAIN; |
| 1397 |
2 |
▶ | enc = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| enc = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
2 |
0 |
2 |
|
| 1398 |
2 |
| PUTBACK; |
| 1399 |
2 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
2 |
0 |
2 |
|
| 1400 |
2 |
| SPAGAIN; |
| 1401 |
2 |
▶ | if (fig) SvREFCNT_dec(fig); |
Branch: 1 branch
| Branch | True | False | Total |
| if (fig) SvREFCNT_dec(fig); |
2 |
0 |
2 |
|
| 1402 |
2 |
| RETVAL = enc; |
| 1403 |
|
| } |
| 1404 |
|
| OUTPUT: |
| 1405 |
|
| RETVAL |
| 1406 |
|
| |
| 1407 |
|
| # A store query, drawn. |
| 1408 |
|
| # |
| 1409 |
|
| # The width is chosen HERE rather than passed in, so that every caller of this |
| 1410 |
|
| # gets the same ladder and two panels over the same window cannot disagree |
| 1411 |
|
| # about how wide a bar is. |
| 1412 |
|
| SV * |
| 1413 |
|
| popl_volume_figure(SV *store, SV *q, SV *from, SV *to) |
| 1414 |
|
| CODE: |
| 1415 |
|
| { |
| 1416 |
22 |
| SV *f = NULL, *t = NULL, *res = NULL, *fig = NULL; |
| 1417 |
22 |
| STRLEN ql = 0; |
| 1418 |
44 |
▶ | const char *qp = SvOK(q) ? SvPV(q, ql) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *qp = SvOK(q) ? SvPV(q, ql) : NULL; |
22 |
0 |
22 |
|
| 1419 |
|
| int got; |
| 1420 |
|
| |
| 1421 |
22 |
| RETVAL = &PL_sv_undef; |
| 1422 |
22 |
| SvREFCNT_inc(RETVAL); |
| 1423 |
22 |
▶ | if (!SvOK(store) || !SvROK(store) || !qp || !ql) goto done; |
Branch: 4 branches
| Branch | True | False | Total |
| if (!SvOK(store) || !SvROK(store) || !qp || !ql) goto done; |
22 |
0 |
22 |
| if (!SvOK(store) || !SvROK(store) || !qp || !ql) goto done; |
22 |
0 |
22 |
| if (!SvOK(store) || !SvROK(store) || !qp || !ql) goto done; |
22 |
0 |
22 |
| if (!SvOK(store) || !SvROK(store) || !qp || !ql) goto done; |
0 |
22 |
22 |
|
| 1424 |
|
| |
| 1425 |
22 |
▶ | f = SvOK(from) ? newSVsv(from) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| f = SvOK(from) ? newSVsv(from) : NULL; |
21 |
1 |
22 |
|
| 1426 |
22 |
▶ | t = SvOK(to) ? newSVsv(to) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| t = SvOK(to) ? newSVsv(to) : NULL; |
21 |
1 |
22 |
|
| 1427 |
|
| |
| 1428 |
|
| /* AN UNBOUNDED WINDOW STILL NEEDS A WIDTH. |
| 1429 |
|
| * |
| 1430 |
|
| * `all` is a real range - it is the escape hatch for data older than |
| 1431 |
|
| * the default - and it arrives with no endpoints at all, so there is |
| 1432 |
|
| * nothing to compute a width from. The span is probed with one coarse |
| 1433 |
|
| * bucketed pass, which is an aggregate and reads no rows out, and the |
| 1434 |
|
| * real width is computed from what came back. |
| 1435 |
|
| * |
| 1436 |
|
| * Two queries only on the one page that has no window. A fixed |
| 1437 |
|
| * default would be a day-wide bar over a thirty-second store, or a |
| 1438 |
|
| * refusal over a year-old one. */ |
| 1439 |
22 |
▶ | if (!f || !t) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!f || !t) { |
21 |
1 |
22 |
| if (!f || !t) { |
0 |
21 |
21 |
|
| 1440 |
1 |
| SV *probe = NULL; |
| 1441 |
1 |
| SV *lo = NULL, *hi = NULL; |
| 1442 |
|
| |
| 1443 |
1 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
1 |
1 |
|
| 1444 |
1 |
▶ | XPUSHs(store); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(store); |
0 |
1 |
1 |
|
| 1445 |
1 |
| { SV *qq = newSVpvn(qp, ql); |
| 1446 |
1 |
| sv_catpvs(qq, " | bucket(1h) count"); |
| 1447 |
1 |
▶ | XPUSHs(sv_2mortal(qq)); } |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(qq)); } |
0 |
1 |
1 |
|
| 1448 |
1 |
▶ | XPUSHs(sv_2mortal(newSVpvs("from"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("from"))); |
0 |
1 |
1 |
|
| 1449 |
1 |
▶ | XPUSHs(sv_2mortal(f ? newSVsv(f) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(f ? newSVsv(f) : newSV(0))); |
0 |
1 |
1 |
| XPUSHs(sv_2mortal(f ? newSVsv(f) : newSV(0))); |
0 |
1 |
1 |
|
| 1450 |
1 |
▶ | XPUSHs(sv_2mortal(newSVpvs("to"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("to"))); |
0 |
1 |
1 |
|
| 1451 |
1 |
▶ | XPUSHs(sv_2mortal(t ? newSVsv(t) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(t ? newSVsv(t) : newSV(0))); |
0 |
1 |
1 |
| XPUSHs(sv_2mortal(t ? newSVsv(t) : newSV(0))); |
0 |
1 |
1 |
|
| 1452 |
1 |
▶ | POVW_NO_CEILING(); |
Branch: 6 branches
| Branch | True | False | Total |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
| POVW_NO_CEILING(); |
0 |
1 |
1 |
|
| 1453 |
1 |
| PUTBACK; |
| 1454 |
1 |
| got = call_method(povw_read_method(aTHX_ store), G_SCALAR | G_EVAL); |
| 1455 |
1 |
| SPAGAIN; |
| 1456 |
1 |
▶ | probe = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| probe = got ? SvREFCNT_inc(POPs) : NULL; |
1 |
0 |
1 |
|
| 1457 |
1 |
| PUTBACK; |
| 1458 |
1 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
1 |
0 |
1 |
|
| 1459 |
1 |
| SPAGAIN; |
| 1460 |
|
| |
| 1461 |
1 |
▶ | if (probe && !SvTRUE(ERRSV) && SvROK(probe) |
Branch: 4 branches
| Branch | True | False | Total |
| if (probe && !SvTRUE(ERRSV) && SvROK(probe) |
1 |
0 |
1 |
| if (probe && !SvTRUE(ERRSV) && SvROK(probe) |
1 |
0 |
1 |
| if (probe && !SvTRUE(ERRSV) && SvROK(probe) |
1 |
0 |
1 |
| if (probe && !SvTRUE(ERRSV) && SvROK(probe) |
1 |
0 |
1 |
|
| 1462 |
1 |
▶ | && SvTYPE(SvRV(probe)) == SVt_PVHV) { |
Branch: 1 branch
| Branch | True | False | Total |
| && SvTYPE(SvRV(probe)) == SVt_PVHV) { |
1 |
0 |
1 |
|
| 1463 |
1 |
| HV *ph = (HV *)SvRV(probe); |
| 1464 |
1 |
| SV **ok = hv_fetchs(ph, "ok", 0); |
| 1465 |
1 |
| SV **sh = hv_fetchs(ph, "shape", 0); |
| 1466 |
1 |
| SV **se = hv_fetchs(ph, "series", 0); |
| 1467 |
1 |
▶ | if (ok && SvTRUE(*ok) && sh && SvOK(*sh) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ok && SvTRUE(*ok) && sh && SvOK(*sh) |
1 |
0 |
1 |
| if (ok && SvTRUE(*ok) && sh && SvOK(*sh) |
1 |
0 |
1 |
| if (ok && SvTRUE(*ok) && sh && SvOK(*sh) |
1 |
0 |
1 |
| if (ok && SvTRUE(*ok) && sh && SvOK(*sh) |
1 |
0 |
1 |
|
| 1468 |
2 |
▶ | && strEQ(SvPV_nolen(*sh), "buckets") |
Branch: 1 branch
| Branch | True | False | Total |
| && strEQ(SvPV_nolen(*sh), "buckets") |
1 |
0 |
1 |
|
| 1469 |
1 |
▶ | && se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| && se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) { |
1 |
0 |
1 |
| && se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) { |
1 |
0 |
1 |
| && se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) { |
1 |
0 |
1 |
|
| 1470 |
1 |
| AV *sa = (AV *)SvRV(*se); |
| 1471 |
1 |
| SSize_t i, n = av_len(sa) + 1; |
| 1472 |
2 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
1 |
1 |
2 |
|
| 1473 |
1 |
| SV **e = av_fetch(sa, i, 0); |
| 1474 |
1 |
▶ | SV **pts = (e && SvROK(*e)) |
Branch: 1 branch
| Branch | True | False | Total |
| SV **pts = (e && SvROK(*e)) |
1 |
0 |
1 |
|
| 1475 |
2 |
▶ | ? hv_fetchs((HV *)SvRV(*e), "points", 0) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? hv_fetchs((HV *)SvRV(*e), "points", 0) : NULL; |
1 |
0 |
1 |
|
| 1476 |
|
| AV *pa; |
| 1477 |
|
| SSize_t j, m; |
| 1478 |
1 |
▶ | if (!pts || !SvROK(*pts)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!pts || !SvROK(*pts)) continue; |
1 |
0 |
1 |
| if (!pts || !SvROK(*pts)) continue; |
0 |
1 |
1 |
|
| 1479 |
1 |
| pa = (AV *)SvRV(*pts); |
| 1480 |
1 |
| m = av_len(pa) + 1; |
| 1481 |
2 |
▶ | for (j = 0; j < m; j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < m; j++) { |
1 |
1 |
2 |
|
| 1482 |
1 |
| SV **p = av_fetch(pa, j, 0); |
| 1483 |
1 |
▶ | SV **at = (p && SvROK(*p)) |
Branch: 1 branch
| Branch | True | False | Total |
| SV **at = (p && SvROK(*p)) |
1 |
0 |
1 |
|
| 1484 |
2 |
▶ | ? av_fetch((AV *)SvRV(*p), 0, 0) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? av_fetch((AV *)SvRV(*p), 0, 0) : NULL; |
1 |
0 |
1 |
|
| 1485 |
1 |
| STRLEN al = 0, cl = 0; |
| 1486 |
|
| const char *ap, *cp; |
| 1487 |
1 |
▶ | if (!at || !SvOK(*at)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!at || !SvOK(*at)) continue; |
1 |
0 |
1 |
| if (!at || !SvOK(*at)) continue; |
0 |
1 |
1 |
|
| 1488 |
1 |
| ap = SvPV(*at, al); |
| 1489 |
1 |
▶ | if (!lo) lo = newSVsv(*at); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!lo) lo = newSVsv(*at); |
1 |
0 |
1 |
|
| 1490 |
|
| else { |
| 1491 |
0 |
| cp = SvPV(lo, cl); |
| 1492 |
0 |
▶ | if (po_ns_cmp_str(ap, (size_t)al, cp, |
Branch: 1 branch
| Branch | True | False | Total |
| if (po_ns_cmp_str(ap, (size_t)al, cp, |
0 |
0 |
0 |
|
| 1493 |
|
| (size_t)cl, NULL) < 0) |
| 1494 |
0 |
| sv_setsv(lo, *at); |
| 1495 |
|
| } |
| 1496 |
1 |
▶ | if (!hi) hi = newSVsv(*at); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hi) hi = newSVsv(*at); |
1 |
0 |
1 |
|
| 1497 |
|
| else { |
| 1498 |
0 |
| cp = SvPV(hi, cl); |
| 1499 |
0 |
▶ | if (po_ns_cmp_str(ap, (size_t)al, cp, |
Branch: 1 branch
| Branch | True | False | Total |
| if (po_ns_cmp_str(ap, (size_t)al, cp, |
0 |
0 |
0 |
|
| 1500 |
|
| (size_t)cl, NULL) > 0) |
| 1501 |
0 |
| sv_setsv(hi, *at); |
| 1502 |
|
| } |
| 1503 |
|
| } |
| 1504 |
|
| } |
| 1505 |
|
| } |
| 1506 |
|
| } |
| 1507 |
1 |
▶ | if (probe) SvREFCNT_dec(probe); |
Branch: 1 branch
| Branch | True | False | Total |
| if (probe) SvREFCNT_dec(probe); |
1 |
0 |
1 |
|
| 1508 |
1 |
▶ | if (!lo || !hi) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!lo || !hi) { |
1 |
0 |
1 |
| if (!lo || !hi) { |
0 |
1 |
1 |
|
| 1509 |
0 |
▶ | if (lo) SvREFCNT_dec(lo); |
Branch: 1 branch
| Branch | True | False | Total |
| if (lo) SvREFCNT_dec(lo); |
0 |
0 |
0 |
|
| 1510 |
0 |
▶ | if (hi) SvREFCNT_dec(hi); |
Branch: 1 branch
| Branch | True | False | Total |
| if (hi) SvREFCNT_dec(hi); |
0 |
0 |
0 |
|
| 1511 |
0 |
| goto done; |
| 1512 |
|
| } |
| 1513 |
1 |
▶ | if (f) SvREFCNT_dec(f); |
Branch: 1 branch
| Branch | True | False | Total |
| if (f) SvREFCNT_dec(f); |
0 |
1 |
1 |
|
| 1514 |
1 |
▶ | if (t) SvREFCNT_dec(t); |
Branch: 1 branch
| Branch | True | False | Total |
| if (t) SvREFCNT_dec(t); |
0 |
1 |
1 |
|
| 1515 |
1 |
| f = lo; |
| 1516 |
|
| { |
| 1517 |
1 |
| po_u64 h = 0; |
| 1518 |
1 |
| (void)po_sv_to_u64(aTHX_ hi, &h); |
| 1519 |
1 |
| t = po_u64_to_sv(po_ns_add(h, 3600000000000ULL)); |
| 1520 |
1 |
| SvREFCNT_dec(hi); |
| 1521 |
|
| } |
| 1522 |
|
| } |
| 1523 |
|
| |
| 1524 |
|
| { |
| 1525 |
|
| const char *width; |
| 1526 |
|
| STRLEN fl, tl; |
| 1527 |
22 |
▶ | const char *fp = SvPV(f, fl); |
Branch: 1 branch
| Branch | True | False | Total |
| const char *fp = SvPV(f, fl); |
10 |
12 |
22 |
|
| 1528 |
22 |
| const char *tp = SvPV(t, tl); |
| 1529 |
|
| SV *qq; |
| 1530 |
|
| |
| 1531 |
22 |
| width = po_plot_bucket_for(fp, (size_t)fl, tp, (size_t)tl); |
| 1532 |
22 |
| qq = newSVpvn(qp, ql); |
| 1533 |
22 |
| sv_catpvs(qq, " | bucket("); |
| 1534 |
22 |
| sv_catpv(qq, width); |
| 1535 |
22 |
| sv_catpvs(qq, ") count by severity"); |
| 1536 |
|
| |
| 1537 |
22 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
22 |
22 |
|
| 1538 |
22 |
▶ | XPUSHs(store); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(store); |
0 |
22 |
22 |
|
| 1539 |
22 |
▶ | XPUSHs(sv_2mortal(qq)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(qq)); |
0 |
22 |
22 |
|
| 1540 |
22 |
▶ | XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(f))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(f))); |
0 |
22 |
22 |
| XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(f))); |
0 |
22 |
22 |
|
| 1541 |
22 |
▶ | XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(t))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(t))); |
0 |
22 |
22 |
| XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(t))); |
0 |
22 |
22 |
|
| 1542 |
22 |
▶ | POVW_NO_CEILING(); |
Branch: 6 branches
| Branch | True | False | Total |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
| POVW_NO_CEILING(); |
0 |
22 |
22 |
|
| 1543 |
22 |
| PUTBACK; |
| 1544 |
22 |
| got = call_method(povw_read_method(aTHX_ store), G_SCALAR | G_EVAL); |
| 1545 |
22 |
| SPAGAIN; |
| 1546 |
22 |
▶ | res = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| res = got ? SvREFCNT_inc(POPs) : NULL; |
22 |
0 |
22 |
|
| 1547 |
22 |
| PUTBACK; |
| 1548 |
22 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
22 |
0 |
22 |
|
| 1549 |
22 |
| SPAGAIN; |
| 1550 |
|
| } |
| 1551 |
|
| |
| 1552 |
22 |
▶ | if (!res || SvTRUE(ERRSV) || !SvROK(res) |
Branch: 4 branches
| Branch | True | False | Total |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
22 |
0 |
22 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
22 |
0 |
22 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
22 |
0 |
22 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
22 |
0 |
22 |
|
| 1553 |
22 |
▶ | || SvTYPE(SvRV(res)) != SVt_PVHV) goto done; |
Branch: 1 branch
| Branch | True | False | Total |
| || SvTYPE(SvRV(res)) != SVt_PVHV) goto done; |
0 |
22 |
22 |
|
| 1554 |
|
| { |
| 1555 |
22 |
| HV *rh = (HV *)SvRV(res); |
| 1556 |
22 |
| SV **ok = hv_fetchs(rh, "ok", 0); |
| 1557 |
22 |
| SV **sh = hv_fetchs(rh, "shape", 0); |
| 1558 |
22 |
| SV **se = hv_fetchs(rh, "series", 0); |
| 1559 |
|
| AV *sa; |
| 1560 |
|
| SSize_t i, n; |
| 1561 |
|
| |
| 1562 |
22 |
▶ | if (!ok || !SvTRUE(*ok)) goto done; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!ok || !SvTRUE(*ok)) goto done; |
22 |
0 |
22 |
| if (!ok || !SvTRUE(*ok)) goto done; |
0 |
22 |
22 |
|
| 1563 |
44 |
▶ | if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) goto done; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) goto done; |
22 |
0 |
22 |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) goto done; |
22 |
0 |
22 |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) goto done; |
0 |
22 |
22 |
|
| 1564 |
22 |
▶ | if (!se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) goto done; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) goto done; |
22 |
0 |
22 |
| if (!se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) goto done; |
22 |
0 |
22 |
| if (!se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) goto done; |
0 |
22 |
22 |
|
| 1565 |
22 |
| sa = (AV *)SvRV(*se); |
| 1566 |
22 |
| n = av_len(sa) + 1; |
| 1567 |
22 |
▶ | if (!n) goto done; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!n) goto done; |
7 |
15 |
22 |
|
| 1568 |
|
| |
| 1569 |
|
| /* The severity arrives as the NUMBER that is stored, because that |
| 1570 |
|
| * is what a query compares. The ramp is keyed by name, so it is |
| 1571 |
|
| * named here. */ |
| 1572 |
37 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
22 |
15 |
37 |
|
| 1573 |
22 |
| SV **e = av_fetch(sa, i, 0); |
| 1574 |
|
| HV *s; |
| 1575 |
|
| SV **key; |
| 1576 |
|
| char buf[64]; |
| 1577 |
|
| size_t bn; |
| 1578 |
22 |
| STRLEN kl = 0; |
| 1579 |
|
| const char *kp; |
| 1580 |
22 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
22 |
0 |
22 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
22 |
0 |
22 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
22 |
22 |
|
| 1581 |
22 |
| s = (HV *)SvRV(*e); |
| 1582 |
22 |
| key = hv_fetchs(s, "key", 0); |
| 1583 |
44 |
▶ | kp = (key && SvOK(*key)) ? SvPV(*key, kl) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| kp = (key && SvOK(*key)) ? SvPV(*key, kl) : NULL; |
22 |
0 |
22 |
| kp = (key && SvOK(*key)) ? SvPV(*key, kl) : NULL; |
22 |
0 |
22 |
|
| 1584 |
22 |
| bn = po_plot_severity_name(kp, (size_t)kl, buf); |
| 1585 |
22 |
| (void)hv_stores(s, "key", newSVpvn(buf, bn)); |
| 1586 |
|
| } |
| 1587 |
|
| } |
| 1588 |
|
| |
| 1589 |
15 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
15 |
15 |
|
| 1590 |
15 |
▶ | XPUSHs(sv_2mortal(newSVsv(res))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(res))); |
0 |
15 |
15 |
|
| 1591 |
15 |
▶ | XPUSHs(sv_2mortal(newSVpvs("unit"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("unit"))); |
0 |
15 |
15 |
|
| 1592 |
15 |
▶ | XPUSHs(sv_2mortal(newSVpvs("lines"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("lines"))); |
0 |
15 |
15 |
|
| 1593 |
15 |
| PUTBACK; |
| 1594 |
15 |
| got = call_pv("Punk::Observe::Plot::severity_bars", G_SCALAR); |
| 1595 |
15 |
| SPAGAIN; |
| 1596 |
15 |
▶ | fig = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| fig = got ? SvREFCNT_inc(POPs) : NULL; |
15 |
0 |
15 |
|
| 1597 |
15 |
| PUTBACK; |
| 1598 |
15 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
15 |
0 |
15 |
|
| 1599 |
15 |
| SPAGAIN; |
| 1600 |
|
| |
| 1601 |
15 |
▶ | if (fig) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fig) { |
0 |
15 |
15 |
|
| 1602 |
15 |
| SvREFCNT_dec(RETVAL); |
| 1603 |
15 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
15 |
15 |
|
| 1604 |
15 |
▶ | XPUSHs(sv_2mortal(newSVsv(fig))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(fig))); |
0 |
15 |
15 |
|
| 1605 |
15 |
| PUTBACK; |
| 1606 |
15 |
| got = call_pv("Punk::Observe::Plot::encode", G_SCALAR); |
| 1607 |
15 |
| SPAGAIN; |
| 1608 |
15 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
15 |
0 |
15 |
|
| 1609 |
15 |
| PUTBACK; |
| 1610 |
15 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
15 |
0 |
15 |
|
| 1611 |
15 |
| SPAGAIN; |
| 1612 |
15 |
| SvREFCNT_dec(fig); |
| 1613 |
|
| } |
| 1614 |
|
| |
| 1615 |
0 |
| done: |
| 1616 |
22 |
▶ | if (f) SvREFCNT_dec(f); |
Branch: 1 branch
| Branch | True | False | Total |
| if (f) SvREFCNT_dec(f); |
22 |
0 |
22 |
|
| 1617 |
22 |
▶ | if (t) SvREFCNT_dec(t); |
Branch: 1 branch
| Branch | True | False | Total |
| if (t) SvREFCNT_dec(t); |
22 |
0 |
22 |
|
| 1618 |
22 |
▶ | if (res) SvREFCNT_dec(res); |
Branch: 1 branch
| Branch | True | False | Total |
| if (res) SvREFCNT_dec(res); |
22 |
0 |
22 |
|
| 1619 |
|
| } |
| 1620 |
|
| OUTPUT: |
| 1621 |
|
| RETVAL |
| 1622 |
|
| |
| 1623 |
|
| # A query result drawn as whatever shape it turned out to be. |
| 1624 |
|
| # |
| 1625 |
|
| # `explore` is one box over every signal, so it cannot know in advance what |
| 1626 |
|
| # shape an answer will take. Dispatching on the shape in ONE place means the |
| 1627 |
|
| # next shape is added in one place. |
| 1628 |
|
| SV * |
| 1629 |
|
| popl_result_figure(SV *res) |
| 1630 |
|
| CODE: |
| 1631 |
|
| { |
| 1632 |
0 |
| HV *r = NULL; |
| 1633 |
|
| SV **sh; |
| 1634 |
|
| int got; |
| 1635 |
|
| |
| 1636 |
0 |
| RETVAL = newSVpvs(""); |
| 1637 |
0 |
▶ | if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN(1); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN(1); |
0 |
0 |
0 |
| if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN(1); |
0 |
0 |
0 |
|
| 1638 |
0 |
| r = (HV *)SvRV(res); |
| 1639 |
0 |
| sh = hv_fetchs(r, "shape", 0); |
| 1640 |
0 |
▶ | if (sh && SvOK(*sh) && strEQ(SvPV_nolen(*sh), "buckets")) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (sh && SvOK(*sh) && strEQ(SvPV_nolen(*sh), "buckets")) { |
0 |
0 |
0 |
| if (sh && SvOK(*sh) && strEQ(SvPV_nolen(*sh), "buckets")) { |
0 |
0 |
0 |
| if (sh && SvOK(*sh) && strEQ(SvPV_nolen(*sh), "buckets")) { |
0 |
0 |
0 |
|
| 1641 |
0 |
| SV *fig = NULL; |
| 1642 |
0 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
0 |
0 |
|
| 1643 |
0 |
▶ | XPUSHs(res); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(res); |
0 |
0 |
0 |
|
| 1644 |
0 |
| PUTBACK; |
| 1645 |
0 |
| got = call_pv("Punk::Observe::Plot::timeseries", G_SCALAR); |
| 1646 |
0 |
| SPAGAIN; |
| 1647 |
0 |
▶ | fig = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| fig = got ? SvREFCNT_inc(POPs) : NULL; |
0 |
0 |
0 |
|
| 1648 |
0 |
| PUTBACK; |
| 1649 |
0 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
0 |
0 |
0 |
|
| 1650 |
0 |
| SPAGAIN; |
| 1651 |
|
| |
| 1652 |
0 |
▶ | if (fig) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fig) { |
0 |
0 |
0 |
|
| 1653 |
0 |
| SvREFCNT_dec(RETVAL); |
| 1654 |
0 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
0 |
0 |
|
| 1655 |
0 |
▶ | XPUSHs(sv_2mortal(newSVsv(fig))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(fig))); |
0 |
0 |
0 |
|
| 1656 |
0 |
| PUTBACK; |
| 1657 |
0 |
| got = call_pv("Punk::Observe::Plot::encode", G_SCALAR); |
| 1658 |
0 |
| SPAGAIN; |
| 1659 |
0 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
0 |
0 |
0 |
|
| 1660 |
0 |
| PUTBACK; |
| 1661 |
0 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
0 |
0 |
0 |
|
| 1662 |
0 |
| SPAGAIN; |
| 1663 |
0 |
| SvREFCNT_dec(fig); |
| 1664 |
|
| } |
| 1665 |
|
| } |
| 1666 |
|
| } |
| 1667 |
|
| OUTPUT: |
| 1668 |
|
| RETVAL |
| 1669 |
|
| |
| 1670 |
|
| # What is arriving, which no total can say. |
| 1671 |
|
| # |
| 1672 |
|
| # LOGS AND SPANS, AND NOT METRICS. `metric` takes a name, so there is no query |
| 1673 |
|
| # for "every metric point" and the overview has no basis on which to pick one |
| 1674 |
|
| # name to stand for the rest. Counting them by choosing a name would be a |
| 1675 |
|
| # chart whose height depended on which metric happened to be chosen, which is |
| 1676 |
|
| # worse than a chart that says what it covers. |
| 1677 |
|
| SV * |
| 1678 |
|
| popl_ingest_figure(SV *store, SV *from, SV *to) |
| 1679 |
|
| CODE: |
| 1680 |
|
| { |
| 1681 |
7 |
| AV *data = newAV(); |
| 1682 |
|
| const char *width; |
| 1683 |
7 |
| STRLEN fl = 0, tl = 0; |
| 1684 |
|
| const char *fp, *tp; |
| 1685 |
7 |
| int sig, got, i = 0; |
| 1686 |
|
| static const char *const SRC[2][2] = { |
| 1687 |
|
| { "log", "logs" }, |
| 1688 |
|
| { "spans", "spans" } |
| 1689 |
|
| }; |
| 1690 |
|
| |
| 1691 |
7 |
| RETVAL = &PL_sv_undef; |
| 1692 |
7 |
| SvREFCNT_inc(RETVAL); |
| 1693 |
7 |
▶ | if (!SvOK(store) || !SvROK(store)) goto done; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvOK(store) || !SvROK(store)) goto done; |
7 |
0 |
7 |
| if (!SvOK(store) || !SvROK(store)) goto done; |
0 |
7 |
7 |
|
| 1694 |
|
| |
| 1695 |
14 |
▶ | fp = SvOK(from) ? SvPV(from, fl) : ""; |
Branch: 1 branch
| Branch | True | False | Total |
| fp = SvOK(from) ? SvPV(from, fl) : ""; |
7 |
0 |
7 |
|
| 1696 |
14 |
▶ | tp = SvOK(to) ? SvPV(to, tl) : ""; |
Branch: 1 branch
| Branch | True | False | Total |
| tp = SvOK(to) ? SvPV(to, tl) : ""; |
7 |
0 |
7 |
|
| 1697 |
7 |
| width = po_plot_bucket_for(fp, (size_t)fl, tp, (size_t)tl); |
| 1698 |
|
| |
| 1699 |
21 |
▶ | for (sig = 0; sig < 2; sig++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (sig = 0; sig < 2; sig++) { |
14 |
7 |
21 |
|
| 1700 |
14 |
| SV *res = NULL; |
| 1701 |
14 |
| SV *xs = NULL, *ys = NULL; |
| 1702 |
|
| HV *trace, *line; |
| 1703 |
|
| HV *rh; |
| 1704 |
|
| SV **ok, **sh, **se, **bn; |
| 1705 |
|
| AV *sa; |
| 1706 |
|
| SV **first, **pts; |
| 1707 |
|
| |
| 1708 |
|
| { |
| 1709 |
14 |
| SV *q = newSVpv(SRC[sig][0], 0); |
| 1710 |
14 |
| sv_catpvs(q, " | bucket("); |
| 1711 |
14 |
| sv_catpv(q, width); |
| 1712 |
14 |
| sv_catpvs(q, ") count"); |
| 1713 |
14 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
14 |
14 |
|
| 1714 |
14 |
▶ | XPUSHs(store); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(store); |
0 |
14 |
14 |
|
| 1715 |
14 |
▶ | XPUSHs(sv_2mortal(q)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(q)); |
0 |
14 |
14 |
|
| 1716 |
14 |
▶ | XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(from))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(from))); |
0 |
14 |
14 |
| XPUSHs(sv_2mortal(newSVpvs("from"))); XPUSHs(sv_2mortal(newSVsv(from))); |
0 |
14 |
14 |
|
| 1717 |
14 |
▶ | XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(to))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(to))); |
0 |
14 |
14 |
| XPUSHs(sv_2mortal(newSVpvs("to"))); XPUSHs(sv_2mortal(newSVsv(to))); |
0 |
14 |
14 |
|
| 1718 |
14 |
▶ | POVW_NO_CEILING(); |
Branch: 6 branches
| Branch | True | False | Total |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
| POVW_NO_CEILING(); |
0 |
14 |
14 |
|
| 1719 |
14 |
| PUTBACK; |
| 1720 |
14 |
| got = call_method(povw_read_method(aTHX_ store), |
| 1721 |
|
| G_SCALAR | G_EVAL); |
| 1722 |
14 |
| SPAGAIN; |
| 1723 |
14 |
▶ | res = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| res = got ? SvREFCNT_inc(POPs) : NULL; |
14 |
0 |
14 |
|
| 1724 |
14 |
| PUTBACK; |
| 1725 |
14 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
14 |
0 |
14 |
|
| 1726 |
14 |
| SPAGAIN; |
| 1727 |
|
| } |
| 1728 |
14 |
▶ | if (!res || SvTRUE(ERRSV) || !SvROK(res) |
Branch: 4 branches
| Branch | True | False | Total |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
14 |
0 |
14 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
14 |
0 |
14 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
14 |
0 |
14 |
| if (!res || SvTRUE(ERRSV) || !SvROK(res) |
14 |
0 |
14 |
|
| 1729 |
14 |
▶ | || SvTYPE(SvRV(res)) != SVt_PVHV) { if (res) SvREFCNT_dec(res); continue; } |
Branch: 2 branches
| Branch | True | False | Total |
| || SvTYPE(SvRV(res)) != SVt_PVHV) { if (res) SvREFCNT_dec(res); continue; } |
0 |
14 |
14 |
| || SvTYPE(SvRV(res)) != SVt_PVHV) { if (res) SvREFCNT_dec(res); continue; } |
0 |
0 |
0 |
|
| 1730 |
14 |
| rh = (HV *)SvRV(res); |
| 1731 |
14 |
| ok = hv_fetchs(rh, "ok", 0); |
| 1732 |
14 |
| sh = hv_fetchs(rh, "shape", 0); |
| 1733 |
14 |
| se = hv_fetchs(rh, "series", 0); |
| 1734 |
14 |
| bn = hv_fetchs(rh, "bucket_ns", 0); |
| 1735 |
14 |
▶ | if (!ok || !SvTRUE(*ok) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!ok || !SvTRUE(*ok) |
14 |
0 |
14 |
| if (!ok || !SvTRUE(*ok) |
14 |
0 |
14 |
|
| 1736 |
28 |
▶ | || !sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets") |
Branch: 3 branches
| Branch | True | False | Total |
| || !sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets") |
14 |
0 |
14 |
| || !sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets") |
14 |
0 |
14 |
| || !sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets") |
14 |
0 |
14 |
|
| 1737 |
14 |
▶ | || !se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| || !se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) { |
14 |
0 |
14 |
| || !se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) { |
14 |
0 |
14 |
| || !se || !SvROK(*se) || SvTYPE(SvRV(*se)) != SVt_PVAV) { |
0 |
14 |
14 |
|
| 1738 |
0 |
| SvREFCNT_dec(res); continue; |
| 1739 |
|
| } |
| 1740 |
|
| /* A SIGNAL THAT RECEIVED NOTHING IS DRAWN AS ZERO, NOT DROPPED. |
| 1741 |
|
| * |
| 1742 |
|
| * The answer succeeded and says none arrived, which is a fact |
| 1743 |
|
| * about the window and belongs on the chart. Omitting the trace |
| 1744 |
|
| * takes its name out of the legend too, so a reader sees a chart |
| 1745 |
|
| * that has only ever had one line on it - and "no spans arrived |
| 1746 |
|
| * in this window" becomes indistinguishable from "the span count |
| 1747 |
|
| * was lost", which is how it gets reported. |
| 1748 |
|
| * |
| 1749 |
|
| * It is the same reasoning the zero-fill below already applies |
| 1750 |
|
| * to a single empty BUCKET, carried to the case where every |
| 1751 |
|
| * bucket is empty. A failed query still skips: that one has not |
| 1752 |
|
| * established anything about the window. */ |
| 1753 |
14 |
| sa = (AV *)SvRV(*se); |
| 1754 |
14 |
| first = av_fetch(sa, 0, 0); |
| 1755 |
5 |
▶ | pts = (first && SvROK(*first) && SvTYPE(SvRV(*first)) == SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| pts = (first && SvROK(*first) && SvTYPE(SvRV(*first)) == SVt_PVHV) |
5 |
0 |
5 |
| pts = (first && SvROK(*first) && SvTYPE(SvRV(*first)) == SVt_PVHV) |
5 |
0 |
5 |
|
| 1756 |
19 |
▶ | ? hv_fetchs((HV *)SvRV(*first), "points", 0) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? hv_fetchs((HV *)SvRV(*first), "points", 0) : NULL; |
5 |
9 |
14 |
|
| 1757 |
14 |
▶ | if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) |
5 |
9 |
14 |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) |
5 |
0 |
5 |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) |
0 |
5 |
5 |
|
| 1758 |
9 |
| pts = NULL; |
| 1759 |
|
| |
| 1760 |
|
| /* Zero-filled and bounded to the WINDOW: these are counts, a |
| 1761 |
|
| * bucket with nothing in it did genuinely receive nothing, and a |
| 1762 |
|
| * window whose traffic all lands in one bucket must still draw |
| 1763 |
|
| * the window rather than a millisecond around that bucket. */ |
| 1764 |
14 |
▶ | if (!pts) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pts) { |
9 |
5 |
14 |
|
| 1765 |
|
| /* Flat zero across the window. Two points rather than a |
| 1766 |
|
| * zero-fill: with no bucket width reported there is nothing |
| 1767 |
|
| * to step by, and a line from one edge to the other says |
| 1768 |
|
| * exactly what happened. */ |
| 1769 |
9 |
| AV *zx = newAV(), *zy = newAV(); |
| 1770 |
9 |
| av_push(zx, po_u64_to_sv(po_plot_ms(fp, (size_t)fl))); |
| 1771 |
9 |
| av_push(zx, po_u64_to_sv(po_plot_ms(tp, (size_t)tl))); |
| 1772 |
9 |
| av_push(zy, newSViv(0)); |
| 1773 |
9 |
| av_push(zy, newSViv(0)); |
| 1774 |
9 |
| xs = newRV_noinc((SV *)zx); |
| 1775 |
9 |
| ys = newRV_noinc((SV *)zy); |
| 1776 |
|
| } |
| 1777 |
|
| else { |
| 1778 |
5 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
5 |
5 |
|
| 1779 |
5 |
▶ | XPUSHs(sv_2mortal(newSVsv(*pts))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(*pts))); |
0 |
5 |
5 |
|
| 1780 |
5 |
▶ | XPUSHs(sv_2mortal(bn ? newSVsv(*bn) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(bn ? newSVsv(*bn) : newSV(0))); |
0 |
5 |
5 |
| XPUSHs(sv_2mortal(bn ? newSVsv(*bn) : newSV(0))); |
5 |
0 |
5 |
|
| 1781 |
5 |
▶ | XPUSHs(sv_2mortal(newSViv(1))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(1))); |
0 |
5 |
5 |
|
| 1782 |
5 |
▶ | XPUSHs(sv_2mortal(newSVsv(from))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(from))); |
0 |
5 |
5 |
|
| 1783 |
5 |
▶ | XPUSHs(sv_2mortal(newSVsv(to))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(to))); |
0 |
5 |
5 |
|
| 1784 |
5 |
| PUTBACK; |
| 1785 |
5 |
| got = call_pv("Punk::Observe::Plot::_fill_gaps", G_LIST); |
| 1786 |
5 |
| SPAGAIN; |
| 1787 |
5 |
▶ | if (got >= 2) { ys = SvREFCNT_inc(POPs); xs = SvREFCNT_inc(POPs); } |
Branch: 1 branch
| Branch | True | False | Total |
| if (got >= 2) { ys = SvREFCNT_inc(POPs); xs = SvREFCNT_inc(POPs); } |
5 |
0 |
5 |
|
| 1788 |
0 |
| else { xs = newRV_noinc((SV *)newAV()); ys = newRV_noinc((SV *)newAV()); } |
| 1789 |
5 |
| PUTBACK; |
| 1790 |
5 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
5 |
0 |
5 |
|
| 1791 |
5 |
| SPAGAIN; |
| 1792 |
|
| } |
| 1793 |
14 |
| SvREFCNT_dec(res); |
| 1794 |
|
| |
| 1795 |
14 |
| trace = newHV(); |
| 1796 |
14 |
| line = newHV(); |
| 1797 |
14 |
| hv_stores(line, "color", newSVpv(po_plot_role(i), 0)); |
| 1798 |
14 |
| hv_stores(line, "width", newSViv(1)); |
| 1799 |
14 |
| hv_stores(trace, "type", newSVpvs("scatter")); |
| 1800 |
14 |
| hv_stores(trace, "mode", newSVpvs("lines")); |
| 1801 |
14 |
| hv_stores(trace, "name", newSVpv(SRC[sig][1], 0)); |
| 1802 |
14 |
| hv_stores(trace, "x", xs); |
| 1803 |
14 |
| hv_stores(trace, "y", ys); |
| 1804 |
14 |
| hv_stores(trace, "stackgroup", newSVpvs("one")); |
| 1805 |
14 |
| hv_stores(trace, "fill", newSVpvs("tonexty")); |
| 1806 |
14 |
| hv_stores(trace, "line", newRV_noinc((SV *)line)); |
| 1807 |
14 |
| av_push(data, newRV_noinc((SV *)trace)); |
| 1808 |
14 |
| i++; |
| 1809 |
|
| } |
| 1810 |
|
| |
| 1811 |
7 |
▶ | if (av_len(data) < 0) goto done; |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(data) < 0) goto done; |
0 |
7 |
7 |
|
| 1812 |
|
| |
| 1813 |
|
| { |
| 1814 |
7 |
| HV *layout = newHV(), *yaxis = newHV(), *title = newHV(); |
| 1815 |
7 |
| HV *xaxis = newHV(), *margin = newHV(); |
| 1816 |
7 |
| AV *range = newAV(); |
| 1817 |
7 |
| SV *fig = NULL; |
| 1818 |
|
| |
| 1819 |
7 |
| hv_stores(title, "text", newSVpvs("records")); |
| 1820 |
7 |
| hv_stores(yaxis, "title", newRV_noinc((SV *)title)); |
| 1821 |
7 |
| hv_stores(yaxis, "rangemode", newSVpvs("tozero")); |
| 1822 |
|
| /* THE AXIS IS THE WINDOW THAT WAS ASKED FOR, not the extent of |
| 1823 |
|
| * what came back. Left to plotly, a quiet hour with one busy |
| 1824 |
|
| * bucket in it auto-scales to that bucket - and the panel then |
| 1825 |
|
| * says "the last hour" above a chart showing a millisecond. */ |
| 1826 |
7 |
| av_push(range, po_u64_to_sv(po_plot_ms(fp, (size_t)fl))); |
| 1827 |
7 |
| av_push(range, po_u64_to_sv(po_plot_ms(tp, (size_t)tl))); |
| 1828 |
7 |
| hv_stores(xaxis, "type", newSVpvs("date")); |
| 1829 |
7 |
| hv_stores(xaxis, "range", newRV_noinc((SV *)range)); |
| 1830 |
7 |
| hv_stores(margin, "l", newSViv(48)); |
| 1831 |
7 |
| hv_stores(margin, "r", newSViv(12)); |
| 1832 |
7 |
| hv_stores(margin, "t", newSViv(8)); |
| 1833 |
7 |
| hv_stores(margin, "b", newSViv(28)); |
| 1834 |
7 |
| hv_stores(layout, "yaxis", newRV_noinc((SV *)yaxis)); |
| 1835 |
7 |
| hv_stores(layout, "xaxis", newRV_noinc((SV *)xaxis)); |
| 1836 |
7 |
| hv_stores(layout, "height", newSViv(200)); |
| 1837 |
7 |
| hv_stores(layout, "margin", newRV_noinc((SV *)margin)); |
| 1838 |
7 |
| hv_stores(layout, "showlegend", newRV_noinc(newSViv(1))); |
| 1839 |
|
| |
| 1840 |
7 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
7 |
7 |
|
| 1841 |
7 |
▶ | XPUSHs(sv_2mortal(newSVpvs("data"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("data"))); |
0 |
7 |
7 |
|
| 1842 |
7 |
▶ | XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_inc((SV *)data))); |
0 |
7 |
7 |
|
| 1843 |
7 |
▶ | XPUSHs(sv_2mortal(newSVpvs("layout"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("layout"))); |
0 |
7 |
7 |
|
| 1844 |
7 |
▶ | XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newRV_noinc((SV *)layout))); |
0 |
7 |
7 |
|
| 1845 |
7 |
| PUTBACK; |
| 1846 |
7 |
| got = call_pv("Punk::Observe::Plot::_fig", G_SCALAR); |
| 1847 |
7 |
| SPAGAIN; |
| 1848 |
7 |
▶ | fig = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| fig = got ? SvREFCNT_inc(POPs) : NULL; |
7 |
0 |
7 |
|
| 1849 |
7 |
| PUTBACK; |
| 1850 |
7 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
7 |
0 |
7 |
|
| 1851 |
7 |
| SPAGAIN; |
| 1852 |
|
| |
| 1853 |
7 |
▶ | if (fig) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fig) { |
0 |
7 |
7 |
|
| 1854 |
7 |
| SvREFCNT_dec(RETVAL); |
| 1855 |
7 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
7 |
7 |
|
| 1856 |
7 |
▶ | XPUSHs(sv_2mortal(newSVsv(fig))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVsv(fig))); |
0 |
7 |
7 |
|
| 1857 |
7 |
| PUTBACK; |
| 1858 |
7 |
| got = call_pv("Punk::Observe::Plot::encode", G_SCALAR); |
| 1859 |
7 |
| SPAGAIN; |
| 1860 |
7 |
▶ | RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
7 |
0 |
7 |
|
| 1861 |
7 |
| PUTBACK; |
| 1862 |
7 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
7 |
0 |
7 |
|
| 1863 |
7 |
| SPAGAIN; |
| 1864 |
7 |
| SvREFCNT_dec(fig); |
| 1865 |
|
| } |
| 1866 |
|
| } |
| 1867 |
|
| |
| 1868 |
0 |
| done: |
| 1869 |
7 |
| SvREFCNT_dec((SV *)data); |
| 1870 |
|
| } |
| 1871 |
|
| OUTPUT: |
| 1872 |
|
| RETVAL |
| 1873 |
|
| |
| 1874 |
|
| # The chart AND the table beneath it, from one answer. |
| 1875 |
|
| # |
| 1876 |
|
| # Both come from the same result rather than from two queries, so the table |
| 1877 |
|
| # cannot disagree with the line above it about what was in the window. |
| 1878 |
|
| void |
| 1879 |
|
| popl_bucket_vars(SV *vars, SV *res) |
| 1880 |
|
| PPCODE: |
| 1881 |
|
| { |
| 1882 |
|
| HV *v, *r; |
| 1883 |
|
| SV **sh, **se; |
| 1884 |
|
| AV *sa, *rows; |
| 1885 |
|
| SSize_t i, n, nrows; |
| 1886 |
26 |
| int got, has_series = 0; |
| 1887 |
|
| /* A table nobody scrolls is a table nobody reads, and every row is |
| 1888 |
|
| * markup the browser has to lay out. */ |
| 1889 |
26 |
| const SSize_t MAXROWS = 500; |
| 1890 |
|
| |
| 1891 |
26 |
▶ | if (!SvROK(vars) || SvTYPE(SvRV(vars)) != SVt_PVHV) XSRETURN_EMPTY; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(vars) || SvTYPE(SvRV(vars)) != SVt_PVHV) XSRETURN_EMPTY; |
26 |
0 |
26 |
| if (!SvROK(vars) || SvTYPE(SvRV(vars)) != SVt_PVHV) XSRETURN_EMPTY; |
0 |
26 |
26 |
|
| 1892 |
26 |
▶ | if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN_EMPTY; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN_EMPTY; |
26 |
0 |
26 |
| if (!SvROK(res) || SvTYPE(SvRV(res)) != SVt_PVHV) XSRETURN_EMPTY; |
0 |
26 |
26 |
|
| 1893 |
26 |
| v = (HV *)SvRV(vars); |
| 1894 |
26 |
| r = (HV *)SvRV(res); |
| 1895 |
26 |
| sh = hv_fetchs(r, "shape", 0); |
| 1896 |
52 |
▶ | if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) |
26 |
0 |
26 |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) |
26 |
0 |
26 |
| if (!sh || !SvOK(*sh) || !strEQ(SvPV_nolen(*sh), "buckets")) |
0 |
26 |
26 |
|
| 1897 |
0 |
| XSRETURN_EMPTY; |
| 1898 |
|
| |
| 1899 |
|
| { |
| 1900 |
26 |
| SV *fig = NULL, *enc = NULL; |
| 1901 |
|
| /* THE PANEL'S OWN CHART KIND. `vars` is the panel, so the viz it |
| 1902 |
|
| * was saved as is already here - it was simply never read, which |
| 1903 |
|
| * is why a panel saved as a bar drew a line. */ |
| 1904 |
26 |
| SV **vz = hv_fetchs(v, "viz", 0); |
| 1905 |
|
| /* A `viz` MEANS THIS IS A PANEL, and a panel gets exactly the one |
| 1906 |
|
| * answer it asked for. The explorer has no viz and wants both: |
| 1907 |
|
| * the chart, and the numbers behind it under the same heading. |
| 1908 |
|
| * Suppressing on the explorer removed the table it exists to |
| 1909 |
|
| * show. */ |
| 1910 |
26 |
▶ | int has_viz = vz && SvOK(*vz) && SvCUR(*vz); |
Branch: 3 branches
| Branch | True | False | Total |
| int has_viz = vz && SvOK(*vz) && SvCUR(*vz); |
22 |
4 |
26 |
| int has_viz = vz && SvOK(*vz) && SvCUR(*vz); |
22 |
0 |
22 |
| int has_viz = vz && SvOK(*vz) && SvCUR(*vz); |
22 |
0 |
22 |
|
| 1911 |
48 |
▶ | const char *kind = has_viz ? SvPV_nolen(*vz) : "line"; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *kind = has_viz ? SvPV_nolen(*vz) : "line"; |
22 |
4 |
26 |
|
| 1912 |
|
| |
| 1913 |
|
| /* `stat` IS NOT A CHART, so it does not get a figure. |
| 1914 |
|
| * |
| 1915 |
|
| * One number, large, is markup - and markup needs no charting |
| 1916 |
|
| * library, survives scripting being off, and is the panel most |
| 1917 |
|
| * likely to be the one somebody glances at. Building it as a |
| 1918 |
|
| * one-point plotly figure would be the library drawing a label. |
| 1919 |
|
| * |
| 1920 |
|
| * The number is the LAST point of the first series: a stat over a |
| 1921 |
|
| * bucketed answer is "what is it now", and averaging the window |
| 1922 |
|
| * would answer a question nobody asked. */ |
| 1923 |
26 |
▶ | if (strEQ(kind, "stat")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(kind, "stat")) { |
3 |
23 |
26 |
|
| 1924 |
3 |
| SV **sv2 = hv_fetchs(r, "series", 0); |
| 1925 |
3 |
| SV *val = NULL; |
| 1926 |
3 |
▶ | if (sv2 && SvROK(*sv2) && SvTYPE(SvRV(*sv2)) == SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (sv2 && SvROK(*sv2) && SvTYPE(SvRV(*sv2)) == SVt_PVAV) { |
2 |
1 |
3 |
| if (sv2 && SvROK(*sv2) && SvTYPE(SvRV(*sv2)) == SVt_PVAV) { |
2 |
0 |
2 |
| if (sv2 && SvROK(*sv2) && SvTYPE(SvRV(*sv2)) == SVt_PVAV) { |
2 |
0 |
2 |
|
| 1927 |
2 |
| AV *sa2 = (AV *)SvRV(*sv2); |
| 1928 |
2 |
| SV **e0 = av_fetch(sa2, 0, 0); |
| 1929 |
2 |
▶ | if (e0 && SvROK(*e0) && SvTYPE(SvRV(*e0)) == SVt_PVHV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (e0 && SvROK(*e0) && SvTYPE(SvRV(*e0)) == SVt_PVHV) { |
2 |
0 |
2 |
| if (e0 && SvROK(*e0) && SvTYPE(SvRV(*e0)) == SVt_PVHV) { |
2 |
0 |
2 |
| if (e0 && SvROK(*e0) && SvTYPE(SvRV(*e0)) == SVt_PVHV) { |
2 |
0 |
2 |
|
| 1930 |
2 |
| SV **pts = hv_fetchs((HV *)SvRV(*e0), "points", 0); |
| 1931 |
2 |
▶ | if (pts && SvROK(*pts) && SvTYPE(SvRV(*pts)) == SVt_PVAV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (pts && SvROK(*pts) && SvTYPE(SvRV(*pts)) == SVt_PVAV) { |
2 |
0 |
2 |
| if (pts && SvROK(*pts) && SvTYPE(SvRV(*pts)) == SVt_PVAV) { |
2 |
0 |
2 |
| if (pts && SvROK(*pts) && SvTYPE(SvRV(*pts)) == SVt_PVAV) { |
2 |
0 |
2 |
|
| 1932 |
|
| /* A POINT IS AN ARRAY, not a hash: the executor |
| 1933 |
|
| * emits [ instant, formatted, value ] and the |
| 1934 |
|
| * third element is the number. Reading it as a |
| 1935 |
|
| * hash is how this shipped rendering "-" over |
| 1936 |
|
| * live data while passing a test written against |
| 1937 |
|
| * a shape the store never produces. */ |
| 1938 |
2 |
| AV *pa = (AV *)SvRV(*pts); |
| 1939 |
2 |
| SSize_t last = av_len(pa); |
| 1940 |
2 |
▶ | if (last >= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (last >= 0) { |
2 |
0 |
2 |
|
| 1941 |
2 |
| SV **lp = av_fetch(pa, last, 0); |
| 1942 |
2 |
▶ | if (lp && SvROK(*lp) |
Branch: 2 branches
| Branch | True | False | Total |
| if (lp && SvROK(*lp) |
2 |
0 |
2 |
| if (lp && SvROK(*lp) |
2 |
0 |
2 |
|
| 1943 |
2 |
▶ | && SvTYPE(SvRV(*lp)) == SVt_PVAV) { |
Branch: 1 branch
| Branch | True | False | Total |
| && SvTYPE(SvRV(*lp)) == SVt_PVAV) { |
2 |
0 |
2 |
|
| 1944 |
2 |
| AV *pt = (AV *)SvRV(*lp); |
| 1945 |
2 |
| SV **y = av_fetch(pt, 2, 0); |
| 1946 |
2 |
▶ | if (y && SvOK(*y)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (y && SvOK(*y)) |
2 |
0 |
2 |
| if (y && SvOK(*y)) |
2 |
0 |
2 |
|
| 1947 |
2 |
| val = newSVpvf("%.4g", (double)SvNV(*y)); |
| 1948 |
|
| } |
| 1949 |
|
| } |
| 1950 |
|
| } |
| 1951 |
|
| } |
| 1952 |
|
| } |
| 1953 |
3 |
▶ | hv_stores(v, "stat_value", val ? val : newSVpvs("-")); |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(v, "stat_value", val ? val : newSVpvs("-")); |
1 |
2 |
3 |
|
| 1954 |
3 |
| XSRETURN_EMPTY; |
| 1955 |
|
| } |
| 1956 |
|
| |
| 1957 |
23 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
23 |
23 |
|
| 1958 |
23 |
▶ | XPUSHs(res); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(res); |
0 |
23 |
23 |
|
| 1959 |
23 |
▶ | XPUSHs(sv_2mortal(newSVpvs("kind"))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvs("kind"))); |
0 |
23 |
23 |
|
| 1960 |
23 |
▶ | XPUSHs(sv_2mortal(newSVpv(kind, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv(kind, 0))); |
0 |
23 |
23 |
|
| 1961 |
23 |
| PUTBACK; |
| 1962 |
23 |
| got = call_pv("Punk::Observe::Plot::timeseries", G_SCALAR); |
| 1963 |
23 |
| SPAGAIN; |
| 1964 |
23 |
▶ | fig = got ? SvREFCNT_inc(POPs) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| fig = got ? SvREFCNT_inc(POPs) : NULL; |
23 |
0 |
23 |
|
| 1965 |
23 |
| PUTBACK; |
| 1966 |
23 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
23 |
0 |
23 |
|
| 1967 |
23 |
| SPAGAIN; |
| 1968 |
|
| |
| 1969 |
23 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
23 |
23 |
|
| 1970 |
23 |
▶ | XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
0 |
23 |
23 |
| XPUSHs(sv_2mortal(fig ? newSVsv(fig) : newSV(0))); |
23 |
0 |
23 |
|
| 1971 |
23 |
| PUTBACK; |
| 1972 |
23 |
| got = call_pv("Punk::Observe::Plot::encode", G_SCALAR); |
| 1973 |
23 |
| SPAGAIN; |
| 1974 |
23 |
▶ | enc = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| enc = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
23 |
0 |
23 |
|
| 1975 |
23 |
| PUTBACK; |
| 1976 |
23 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
23 |
0 |
23 |
|
| 1977 |
23 |
| SPAGAIN; |
| 1978 |
23 |
▶ | if (fig) SvREFCNT_dec(fig); |
Branch: 1 branch
| Branch | True | False | Total |
| if (fig) SvREFCNT_dec(fig); |
23 |
0 |
23 |
|
| 1979 |
|
| /* ONE ANSWER, NOT TWO. |
| 1980 |
|
| * |
| 1981 |
|
| * This used to set both halves and leave the caller to delete the |
| 1982 |
|
| * one it did not want - so the knowledge of what a viz means sat |
| 1983 |
|
| * in two files, and calling this function on its own produced a |
| 1984 |
|
| * panel that was a chart AND a table. The viz is right here; the |
| 1985 |
|
| * decision belongs here with it. */ |
| 1986 |
23 |
▶ | if (has_viz && strEQ(kind, "table")) SvREFCNT_dec(enc); |
Branch: 2 branches
| Branch | True | False | Total |
| if (has_viz && strEQ(kind, "table")) SvREFCNT_dec(enc); |
19 |
4 |
23 |
| if (has_viz && strEQ(kind, "table")) SvREFCNT_dec(enc); |
5 |
14 |
19 |
|
| 1987 |
18 |
| else (void)hv_stores(v, "series_plot", enc); |
| 1988 |
|
| } |
| 1989 |
|
| |
| 1990 |
23 |
| rows = newAV(); |
| 1991 |
23 |
| se = hv_fetchs(r, "series", 0); |
| 1992 |
19 |
▶ | sa = (se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) |
Branch: 2 branches
| Branch | True | False | Total |
| sa = (se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) |
19 |
0 |
19 |
| sa = (se && SvROK(*se) && SvTYPE(SvRV(*se)) == SVt_PVAV) |
19 |
0 |
19 |
|
| 1993 |
42 |
▶ | ? (AV *)SvRV(*se) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? (AV *)SvRV(*se) : NULL; |
19 |
4 |
23 |
|
| 1994 |
23 |
▶ | n = sa ? av_len(sa) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| n = sa ? av_len(sa) + 1 : 0; |
19 |
4 |
23 |
|
| 1995 |
52 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
29 |
23 |
52 |
|
| 1996 |
29 |
| SV **e = av_fetch(sa, i, 0); |
| 1997 |
|
| HV *s; |
| 1998 |
|
| SV **key, **pts; |
| 1999 |
|
| AV *pa; |
| 2000 |
|
| SSize_t j, m; |
| 2001 |
29 |
| STRLEN kl = 0; |
| 2002 |
29 |
| const char *kp = ""; |
| 2003 |
|
| |
| 2004 |
29 |
▶ | if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
29 |
0 |
29 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
29 |
0 |
29 |
| if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVHV) continue; |
0 |
29 |
29 |
|
| 2005 |
29 |
| s = (HV *)SvRV(*e); |
| 2006 |
29 |
| key = hv_fetchs(s, "key", 0); |
| 2007 |
58 |
▶ | if (key && SvOK(*key)) { kp = SvPV(*key, kl); if (kl) has_series = 1; } |
Branch: 3 branches
| Branch | True | False | Total |
| if (key && SvOK(*key)) { kp = SvPV(*key, kl); if (kl) has_series = 1; } |
29 |
0 |
29 |
| if (key && SvOK(*key)) { kp = SvPV(*key, kl); if (kl) has_series = 1; } |
29 |
0 |
29 |
| if (key && SvOK(*key)) { kp = SvPV(*key, kl); if (kl) has_series = 1; } |
23 |
6 |
29 |
|
| 2008 |
29 |
| pts = hv_fetchs(s, "points", 0); |
| 2009 |
29 |
▶ | if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) continue; |
29 |
0 |
29 |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) continue; |
29 |
0 |
29 |
| if (!pts || !SvROK(*pts) || SvTYPE(SvRV(*pts)) != SVt_PVAV) continue; |
0 |
29 |
29 |
|
| 2010 |
29 |
| pa = (AV *)SvRV(*pts); |
| 2011 |
29 |
| m = av_len(pa) + 1; |
| 2012 |
76 |
▶ | for (j = 0; j < m; j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < m; j++) { |
47 |
29 |
76 |
|
| 2013 |
47 |
| SV **p = av_fetch(pa, j, 0); |
| 2014 |
|
| AV *row; |
| 2015 |
|
| AV *out; |
| 2016 |
47 |
▶ | if (!p || !SvROK(*p) || SvTYPE(SvRV(*p)) != SVt_PVAV) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!p || !SvROK(*p) || SvTYPE(SvRV(*p)) != SVt_PVAV) continue; |
47 |
0 |
47 |
| if (!p || !SvROK(*p) || SvTYPE(SvRV(*p)) != SVt_PVAV) continue; |
47 |
0 |
47 |
| if (!p || !SvROK(*p) || SvTYPE(SvRV(*p)) != SVt_PVAV) continue; |
0 |
47 |
47 |
|
| 2017 |
47 |
| row = (AV *)SvRV(*p); |
| 2018 |
47 |
| out = newAV(); |
| 2019 |
47 |
| { SV **t = av_fetch(row, 0, 0); |
| 2020 |
47 |
▶ | av_push(out, t ? newSVsv(*t) : newSV(0)); } |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(out, t ? newSVsv(*t) : newSV(0)); } |
47 |
0 |
47 |
|
| 2021 |
47 |
| av_push(out, newSVpvn(kp, kl)); |
| 2022 |
47 |
| { SV **val = av_fetch(row, 1, 0); |
| 2023 |
47 |
▶ | av_push(out, val ? newSVsv(*val) : newSV(0)); } |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(out, val ? newSVsv(*val) : newSV(0)); } |
47 |
0 |
47 |
|
| 2024 |
47 |
| { SV **c = av_fetch(row, 2, 0); |
| 2025 |
47 |
▶ | av_push(out, c ? newSVsv(*c) : newSV(0)); } |
Branch: 1 branch
| Branch | True | False | Total |
| av_push(out, c ? newSVsv(*c) : newSV(0)); } |
45 |
2 |
47 |
|
| 2026 |
47 |
| av_push(rows, newRV_noinc((SV *)out)); |
| 2027 |
|
| } |
| 2028 |
|
| } |
| 2029 |
|
| |
| 2030 |
|
| /* By instant, DESCENDING. Compared as decimal strings - width then |
| 2031 |
|
| * value - because a nanosecond instant past 2^53 does not survive |
| 2032 |
|
| * being made a number, and two buckets a microsecond apart would then |
| 2033 |
|
| * sort as equal. */ |
| 2034 |
23 |
| nrows = av_len(rows) + 1; |
| 2035 |
23 |
▶ | if (nrows > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nrows > 1) { |
12 |
11 |
23 |
|
| 2036 |
12 |
| SV **arr = AvARRAY(rows); |
| 2037 |
|
| SSize_t x; |
| 2038 |
40 |
▶ | for (x = 1; x < nrows; x++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (x = 1; x < nrows; x++) { |
28 |
12 |
40 |
|
| 2039 |
28 |
| SV *k = arr[x]; |
| 2040 |
28 |
| SV **kt = av_fetch((AV *)SvRV(k), 0, 0); |
| 2041 |
28 |
| STRLEN kl = 0; |
| 2042 |
56 |
▶ | const char *kp = (kt && SvOK(*kt)) ? SvPV(*kt, kl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *kp = (kt && SvOK(*kt)) ? SvPV(*kt, kl) : ""; |
28 |
0 |
28 |
| const char *kp = (kt && SvOK(*kt)) ? SvPV(*kt, kl) : ""; |
28 |
0 |
28 |
|
| 2043 |
|
| SSize_t y; |
| 2044 |
54 |
▶ | for (y = x - 1; y >= 0; y--) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (y = x - 1; y >= 0; y--) { |
44 |
10 |
54 |
|
| 2045 |
44 |
| SV **jt = av_fetch((AV *)SvRV(arr[y]), 0, 0); |
| 2046 |
44 |
| STRLEN jl = 0; |
| 2047 |
88 |
▶ | const char *jp = (jt && SvOK(*jt)) ? SvPV(*jt, jl) : ""; |
Branch: 2 branches
| Branch | True | False | Total |
| const char *jp = (jt && SvOK(*jt)) ? SvPV(*jt, jl) : ""; |
44 |
0 |
44 |
| const char *jp = (jt && SvOK(*jt)) ? SvPV(*jt, jl) : ""; |
44 |
0 |
44 |
|
| 2048 |
44 |
▶ | if (po_ns_cmp_str(jp, (size_t)jl, kp, (size_t)kl, NULL) >= 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (po_ns_cmp_str(jp, (size_t)jl, kp, (size_t)kl, NULL) >= 0) |
18 |
26 |
44 |
|
| 2049 |
18 |
| break; |
| 2050 |
26 |
| arr[y + 1] = arr[y]; |
| 2051 |
|
| } |
| 2052 |
28 |
| arr[y + 1] = k; |
| 2053 |
|
| } |
| 2054 |
|
| } |
| 2055 |
|
| |
| 2056 |
23 |
▶ | (void)hv_stores(v, "bucket_truncated", |
Branch: 1 branch
| Branch | True | False | Total |
| (void)hv_stores(v, "bucket_truncated", |
0 |
23 |
23 |
|
| 2057 |
|
| newSViv(nrows > MAXROWS ? (IV)nrows : 0)); |
| 2058 |
23 |
▶ | if (nrows > MAXROWS) nrows = MAXROWS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (nrows > MAXROWS) nrows = MAXROWS; |
0 |
23 |
23 |
|
| 2059 |
|
| |
| 2060 |
|
| { |
| 2061 |
23 |
| AV *out = newAV(); |
| 2062 |
|
| SSize_t x; |
| 2063 |
70 |
▶ | for (x = 0; x < nrows; x++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (x = 0; x < nrows; x++) { |
47 |
23 |
70 |
|
| 2064 |
47 |
| SV **e = av_fetch(rows, x, 0); |
| 2065 |
|
| AV *row; |
| 2066 |
|
| HV *o; |
| 2067 |
|
| SV **t, **k, **val, **c; |
| 2068 |
|
| char b[64]; |
| 2069 |
|
| size_t bl; |
| 2070 |
47 |
| STRLEN tl = 0; |
| 2071 |
|
| const char *tp; |
| 2072 |
|
| |
| 2073 |
47 |
▶ | if (!e || !SvROK(*e)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!e || !SvROK(*e)) continue; |
47 |
0 |
47 |
| if (!e || !SvROK(*e)) continue; |
0 |
47 |
47 |
|
| 2074 |
47 |
| row = (AV *)SvRV(*e); |
| 2075 |
47 |
| o = newHV(); |
| 2076 |
47 |
| t = av_fetch(row, 0, 0); |
| 2077 |
94 |
▶ | tp = (t && SvOK(*t)) ? SvPV(*t, tl) : "0"; |
Branch: 2 branches
| Branch | True | False | Total |
| tp = (t && SvOK(*t)) ? SvPV(*t, tl) : "0"; |
47 |
0 |
47 |
| tp = (t && SvOK(*t)) ? SvPV(*t, tl) : "0"; |
47 |
0 |
47 |
|
| 2078 |
47 |
▶ | hv_stores(o, "t", t ? newSVsv(*t) : newSV(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(o, "t", t ? newSVsv(*t) : newSV(0)); |
47 |
0 |
47 |
|
| 2079 |
47 |
| bl = po_fmt_time(tp, (size_t)tl, b); |
| 2080 |
47 |
| hv_stores(o, "time", newSVpvn(b, bl)); |
| 2081 |
47 |
| k = av_fetch(row, 1, 0); |
| 2082 |
47 |
▶ | hv_stores(o, "series", (k && SvOK(*k) && SvCUR(*k)) |
Branch: 3 branches
| Branch | True | False | Total |
| hv_stores(o, "series", (k && SvOK(*k) && SvCUR(*k)) |
47 |
0 |
47 |
| hv_stores(o, "series", (k && SvOK(*k) && SvCUR(*k)) |
47 |
0 |
47 |
| hv_stores(o, "series", (k && SvOK(*k) && SvCUR(*k)) |
41 |
6 |
47 |
|
| 2083 |
|
| ? newSVsv(*k) : newSVpvs("(all)")); |
| 2084 |
47 |
| val = av_fetch(row, 2, 0); |
| 2085 |
|
| { |
| 2086 |
47 |
| SV *num = NULL; |
| 2087 |
47 |
▶ | ENTER; SAVETMPS; PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| ENTER; SAVETMPS; PUSHMARK(SP); |
0 |
47 |
47 |
|
| 2088 |
47 |
▶ | XPUSHs(sv_2mortal(val ? newSVsv(*val) : newSV(0))); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(val ? newSVsv(*val) : newSV(0))); |
0 |
47 |
47 |
| XPUSHs(sv_2mortal(val ? newSVsv(*val) : newSV(0))); |
47 |
0 |
47 |
|
| 2089 |
47 |
| PUTBACK; |
| 2090 |
47 |
| got = call_pv("Punk::Observe::Plot::_num", G_SCALAR); |
| 2091 |
47 |
| SPAGAIN; |
| 2092 |
47 |
▶ | num = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
Branch: 1 branch
| Branch | True | False | Total |
| num = got ? SvREFCNT_inc(POPs) : newSVpvs(""); |
47 |
0 |
47 |
|
| 2093 |
47 |
| PUTBACK; |
| 2094 |
47 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
47 |
0 |
47 |
|
| 2095 |
47 |
| SPAGAIN; |
| 2096 |
47 |
| hv_stores(o, "value", num); |
| 2097 |
|
| } |
| 2098 |
47 |
| c = av_fetch(row, 3, 0); |
| 2099 |
47 |
▶ | hv_stores(o, "count", c ? newSVsv(*c) : newSV(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| hv_stores(o, "count", c ? newSVsv(*c) : newSV(0)); |
47 |
0 |
47 |
|
| 2100 |
47 |
| av_push(out, newRV_noinc((SV *)o)); |
| 2101 |
|
| } |
| 2102 |
|
| { |
| 2103 |
23 |
| SV **vz3 = hv_fetchs(v, "viz", 0); |
| 2104 |
23 |
▶ | int hv3 = vz3 && SvOK(*vz3) && SvCUR(*vz3); |
Branch: 3 branches
| Branch | True | False | Total |
| int hv3 = vz3 && SvOK(*vz3) && SvCUR(*vz3); |
19 |
4 |
23 |
| int hv3 = vz3 && SvOK(*vz3) && SvCUR(*vz3); |
19 |
0 |
19 |
| int hv3 = vz3 && SvOK(*vz3) && SvCUR(*vz3); |
19 |
0 |
19 |
|
| 2105 |
42 |
▶ | const char *k3 = hv3 ? SvPV_nolen(*vz3) : "line"; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *k3 = hv3 ? SvPV_nolen(*vz3) : "line"; |
19 |
4 |
23 |
|
| 2106 |
23 |
▶ | if (!hv3 || strEQ(k3, "table")) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!hv3 || strEQ(k3, "table")) |
19 |
4 |
23 |
| if (!hv3 || strEQ(k3, "table")) |
5 |
14 |
19 |
|
| 2107 |
9 |
| (void)hv_stores(v, "bucket_rows", newRV_noinc((SV *)out)); |
| 2108 |
|
| else |
| 2109 |
14 |
| SvREFCNT_dec((SV *)out); |
| 2110 |
|
| } |
| 2111 |
|
| } |
| 2112 |
23 |
| SvREFCNT_dec((SV *)rows); |
| 2113 |
23 |
| (void)hv_stores(v, "has_series", newSViv(has_series)); |
| 2114 |
23 |
| XSRETURN_EMPTY; |
| 2115 |
|
| } |