kanat is too fat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

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;
}