68kcounter
Version:
68000 ASM source code cycle counter
41 lines (40 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateTotals = void 0;
/**
* Total timings and lengths across a range of lines
*/
function calculateTotals(lines) {
let bytes = 0;
let bssBytes = 0;
let objectBytes = 0;
const min = [0, 0, 0];
const max = [0, 0, 0];
for (const line of lines) {
if (line.bytes) {
bytes += line.bytes;
if (line.bss) {
bssBytes += line.bytes;
}
else {
objectBytes += line.bytes;
}
}
const timings = line.timing?.values;
if (!timings) {
continue;
}
const clocks = timings.map((n) => n[0]);
const reads = timings.map((n) => n[1]);
const writes = timings.map((n) => n[2]);
min[0] += Math.min(...clocks);
min[1] += Math.min(...reads);
min[2] += Math.min(...writes);
max[0] += Math.max(...clocks);
max[1] += Math.max(...reads);
max[2] += Math.max(...writes);
}
const isRange = min[0] !== max[0] || min[1] !== max[1] || min[2] !== max[2];
return { min, max, isRange, bytes, bssBytes, objectBytes };
}
exports.calculateTotals = calculateTotals;