Initial commit

This commit is contained in:
Kuba Orlik 2021-10-01 22:02:49 +02:00
commit 435b00ca25

60
measure-drift.mjs Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/zx
const label_file_path = process.argv.slice(-1)[0];
const labels = (await $`cat ${label_file_path}`).stdout
.split("\n")
.filter((e) => e != "")
.map((l) => l.split("\t"))
.map(([start, stop, label]) => {
const suffix = label.match(/-[^-]+$/)[0];
const filename = label.replace(suffix, "");
return {
time: parseFloat(start),
label,
filename,
suffix: suffix.slice(1),
};
})
.reduce((acc, element) => {
if (!acc[element.filename]) {
acc[element.filename] = {
labels: {},
};
}
acc[element.filename].labels[element.suffix] = element.time;
return acc;
}, {});
console.log(labels);
for (let filename in labels) {
const filelabels = labels[filename].labels;
for (const suffix of ["A", "B"]) {
const duration =
filelabels[`end${suffix}`] - filelabels[`start${suffix}`] || null;
const key = `duration[${suffix}]`;
labels[filename][key] = duration;
}
}
for (let filename1 in labels) {
for (let filename2 in labels) {
if (filename1 === filename2) {
continue;
}
for (const suffix of ["A", "B"]) {
const key = `duration[${suffix}]`;
if (labels[filename1][key] && labels[filename2][key]) {
console.log(
filename1,
"/",
filename2,
labels[filename1][key] / labels[filename2][key]
);
break;
}
}
}
}