{#- Spans drawn as a table, for the Timing panel and the generic one: each span a row with a track on the request's clock (issue 737). A period is a bar placed where it starts and as wide as it lasts; an event is a diamond at its moment, with a dashed line through every row's track; a span made of several segments draws each of them on its one line, and one of a single segment draws as an ordinary bar. Each bar, segment and event carries the text of its tooltip in data-tip, which the toolbar's and the dashboard's script show in one floating element on hover, on keyboard focus and on tap. -#} {%- macro place(start, duration, total) -%} {%- set from = [[(start * 100 / total)|round|int, 0]|max, 100]|min if total > 0 else 0 -%} {%- set width = [[(duration * 100 / total)|round|int, 0]|max, 100 - from]|min if total > 0 else 0 -%} from-{{ from }} for-{{ width }} {%- endmacro -%} {%- macro ms(value) -%}{{ value|round(2) }} ms{%- endmacro -%} {%- macro period(name, start, duration, failed, detail) -%} {{ name }} starts at {{ ms(start) }} takes {{ ms(duration) }}{% if failed %} failed{% endif %}{% if detail %} {{ detail }}{% endif %} {%- endmacro -%} {#- An event's index among the panel's, which names its dashed line. -#} {%- macro mark(events, at) -%} {%- set found = namespace(index=-1) -%} {%- for one in events %}{% if found.index < 0 and one == at %}{% set found.index = loop.index0 %}{% endif %}{% endfor -%} {%- if found.index >= 0 %} event-{{ found.index }}{% endif -%} {%- endmacro -%} {%- macro track(span, total, events) -%} {%- for at in events %}{% endfor -%} {%- if span.at_ms is not none -%} {%- elif span.segments|length > 1 -%} {%- for segment in span.segments -%} {%- endfor -%} {%- elif span.segments -%} {%- set only = span.segments[0] -%} {%- else -%} {%- endif -%} {%- endmacro -%} {#- The table: `heading` names the first column, `total` is the length of the clock the tracks show, and `events` the moments of the panel's events, whose dashed lines every track carries. -#} {%- macro table(spans, total, events, heading) -%}
| {{ heading }} | Starts | Takes | On the request's clock | ||||||
|---|---|---|---|---|---|---|---|---|---|
| {% if span.failed %}✕ {% endif %}{% if event %}{{ span.name }}{% else %}{{ span.name }}{% endif %} | {%- if event %}{{ ms(span.at_ms) }} | – | {%- elif span.segments|length > 1 %}{{ span.segments|length }} segments | {{ ms(span.segments|map(attribute="duration_ms")|sum) }} | {%- elif span.segments %}{{ ms(span.segments[0].start_ms) }} | {{ ms(span.segments[0].duration_ms) }} | {%- else %}{{ ms(span.start_ms) }} | {{ ms(span.duration_ms) }} | {%- endif %}{{ track(span, total, events) }} |