commit 435b00ca251d68b77ebb975c6b6323193783a71f Author: Kuba Orlik Date: Fri Oct 1 22:02:49 2021 +0200 Initial commit diff --git a/measure-drift.mjs b/measure-drift.mjs new file mode 100755 index 0000000..1ac979a --- /dev/null +++ b/measure-drift.mjs @@ -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; + } + } + } +}