diff --git a/src/cargo/core/compiler/timings-svg.js b/src/cargo/core/compiler/timings-svg.js new file mode 100644 index 00000000000..cd05efc32e9 --- /dev/null +++ b/src/cargo/core/compiler/timings-svg.js @@ -0,0 +1,259 @@ +const X_LINE = 50; +const MARGIN = 5; +const Y_LINE = 35; // relative to bottom +const PX_PER_SEC = 20.0; +const MIN_TICK_DIST = 50; + +function svgNode(name, attrs) { + let n = document.createElementNS("http://www.w3.org/2000/svg", name); + for (const attr in attrs) { + n.setAttributeNS(null, attr, attrs[attr]); + } + return n; +} + +function render_pipeline_graph() { + let g = document.getElementById('pipeline-graph'); + const BOX_HEIGHT = 25; + const Y_TICK_DIST = BOX_HEIGHT + 2; + + let graph_height = Y_TICK_DIST * UNIT_DATA.length; + let graph_width = draw_graph_axes(g, graph_height); + + // Draw Y tick marks. + let y_ticks_d = ''; + for (n=1; n + + + Waiting + + + Active + + + Inactive + `; + graph.appendChild(placeholder.firstChild); +} + +function draw_graph_axes(g, graph_height) { + let graph_width = PX_PER_SEC * DURATION; + let width = graph_width + X_LINE + 30; + let height = graph_height + MARGIN + Y_LINE; + g.setAttribute("width", width); + g.setAttribute("height", height); + + let labels = []; + let graph_axes_d = `M ${X_LINE} ${MARGIN} + l 0 ${graph_height} + l ${graph_width+20} 0 `; + + // Draw X tick marks. + let tick_width = graph_width - 10; + let [step, top] = split_ticks(DURATION, tick_width / MIN_TICK_DIST); + let num_ticks = top / step; + let tick_dist = tick_width / num_ticks; + for (n=0; n