diff --git a/default.css b/default.css index 062217e..b9937ac 100644 --- a/default.css +++ b/default.css @@ -9,3 +9,8 @@ html, body { body .main { height: 100%; } + +.main #c { + width: 100%; + height: 100%; +} diff --git a/geometry.js b/geometry.js new file mode 100644 index 0000000..51cc80c --- /dev/null +++ b/geometry.js @@ -0,0 +1,65 @@ +let colors = {}; + +function get_color(stage_name) { + if (stage_name in colors) { + return colors[stage_name]; + } + + const r = Math.floor(Math.random() * 155); + const g = Math.floor(Math.random() * 155); + const b = Math.floor(Math.random() * 155); + + colors[stage_name] = { 'r': 100 + r, 'g': 100 + g, 'b': 100 + b }; + + return colors[stage_name]; +} + +function generate(trace_id) { + const result = { + 'count': 0, + }; + + const positions = []; + const sizes = []; + const colors = []; + + let instructions = []; + + if (trace_id in traces) { + instructions = traces[trace_id]; + } + + console.log(instructions); + + let y = 0; + + for (const instruction of instructions) { + for (let i = 0; i < instruction.lanes['0'].length; ++i) { + const stage = instruction.lanes['0'][i]; + let stage_cycles; + + if (i < instruction.lanes['0'].length - 1) { + const next_stage = instruction.lanes['0'][i + 1]; + stage_cycles = next_stage.c - stage.c; + } else { + stage_cycles = instruction.retcyc - stage.c; + } + + const color = get_color(stage.name); + + sizes.push(stage_cycles * config.w, 1 * config.h); + positions.push(config.w * stage.c, config.h * y); + colors.push(color.r, color.g, color.b, 255); + + result.count++; + } + + ++y; + } + + result.pos = new Float32Array(positions); + result.size = new Float32Array(sizes); + result.color = new Uint8Array(colors); + + return result; +} diff --git a/index.html b/index.html index 4b71c67..a828e3f 100644 --- a/index.html +++ b/index.html @@ -15,9 +15,11 @@ +