mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
viz: only send trace duration (#11789)
* viz: only send trace duration * can unwrap
This commit is contained in:
parent
1c81ec9248
commit
38f0fa7bde
2 changed files with 5 additions and 5 deletions
|
|
@ -151,7 +151,7 @@ async function renderProfiler() {
|
|||
// layout once!
|
||||
if (data != null) return;
|
||||
const profiler = d3.select(".profiler").html("");
|
||||
const { layout, st, et } = await (await fetch("/get_profile")).json();
|
||||
const { layout, dur } = await (await fetch("/get_profile")).json();
|
||||
// place devices on the y axis and set vertical positions
|
||||
const [tickSize, padding] = [10, 8];
|
||||
const deviceList = profiler.append("div").attr("id", "device-list").style("padding-top", tickSize+padding+"px");
|
||||
|
|
@ -162,7 +162,7 @@ async function renderProfiler() {
|
|||
const canvasTop = rect(canvas).top;
|
||||
// color by key (name/category/device)
|
||||
const colorMap = new Map();
|
||||
data = {tracks:new Map(), axes:{}, st, et};
|
||||
data = {tracks:new Map(), axes:{}};
|
||||
const heightScale = d3.scaleLinear().domain([0, Object.entries(layout).reduce((peak, [_,d]) => Math.max(peak, d.peak||0), 0)]).range([4,maxheight=100]);
|
||||
for (const [k, v] of Object.entries(layout)) {
|
||||
if (v.shapes.length === 0) continue;
|
||||
|
|
@ -225,7 +225,7 @@ async function renderProfiler() {
|
|||
ctx.save();
|
||||
ctx.clearRect(0, 0, canvas.clientWidth, canvas.clientHeight);
|
||||
// rescale to match current zoom
|
||||
const xscale = d3.scaleLinear().domain([0, et-st]).range([0, canvas.clientWidth]);
|
||||
const xscale = d3.scaleLinear().domain([0, dur]).range([0, canvas.clientWidth]);
|
||||
xscale.domain(xscale.range().map(zoomLevel.invertX, zoomLevel).map(xscale.invert, xscale));
|
||||
const zoomDomain = transform != null ? xscale.domain() : null;
|
||||
let yscale = null;
|
||||
|
|
@ -289,7 +289,7 @@ async function renderProfiler() {
|
|||
// tick label
|
||||
ctx.textBaseline = "top";
|
||||
ctx.textAlign = "left";
|
||||
ctx.fillText(formatTime(tick, et-st), x+ctx.lineWidth+2, tickSize);
|
||||
ctx.fillText(formatTime(tick, dur), x+ctx.lineWidth+2, tickSize);
|
||||
}
|
||||
if (yscale != null) {
|
||||
drawLine(ctx, [0, 0], yscale.range());
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ def get_profile(profile:list[ProfileEvent]) -> bytes|None:
|
|||
v.sort(key=lambda e:e[0])
|
||||
layout[k] = timeline_layout(v, start_ts)
|
||||
layout[f"{k} Memory"] = mem_layout(v, start_ts, unwrap(end_ts))
|
||||
return json.dumps({"layout":layout, "st":start_ts, "et":end_ts}).encode("utf-8")
|
||||
return json.dumps({"layout":layout, "dur":unwrap(end_ts)-start_ts}).encode("utf-8")
|
||||
|
||||
def get_runtime_stats(key) -> list[dict]:
|
||||
ret:list[dict] = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue