Refactor: Remove stale benchmark outputs

This commit is contained in:
github-actions[bot]
2026-03-05 07:51:26 +00:00
parent 47ccd20b71
commit 35f7fc8803
35 changed files with 0 additions and 882 deletions

View File

@@ -1,94 +0,0 @@
const _luxon = import("https://cdn.jsdelivr.net/npm/luxon@3.5.0/+esm");
const findAvailableSlots = async (calA = [], calB = [], c = {}) => {
const { DateTime } = await _luxon;
const durMin = c?.durationMinutes;
const sr = c?.searchRange;
const wh = c?.workHours;
if (!Number.isFinite(durMin) || durMin <= 0) throw new TypeError("Invalid durationMinutes");
if (!sr?.start || !sr?.end) throw new TypeError("Invalid searchRange");
if (!wh?.start || !wh?.end) throw new TypeError("Invalid workHours");
const parseHm = s => {
const m = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(String(s).trim());
if (!m) throw new TypeError("Invalid workHours time");
return { h: +m[1], m: +m[2] };
};
const rs = DateTime.fromISO(sr.start, { zone: "utc" });
const re = DateTime.fromISO(sr.end, { zone: "utc" });
if (!rs.isValid || !re.isValid) throw new TypeError("Invalid searchRange ISO");
const rS = rs.toMillis(), rE = re.toMillis();
if (!(rE > rS)) return [];
const ws = parseHm(wh.start), we = parseHm(wh.end);
if (we.h * 60 + we.m <= ws.h * 60 + ws.m) throw new TypeError("workHours.end must be after workHours.start");
const durMs = Math.round(durMin * 60000);
if (durMs <= 0) throw new TypeError("Invalid durationMinutes");
const norm = x => {
const s = DateTime.fromISO(x.start, { zone: "utc" });
const e = DateTime.fromISO(x.end, { zone: "utc" });
if (!s.isValid || !e.isValid) return null;
let a = s.toMillis(), b = e.toMillis();
if (!(b > a)) return null;
if (b <= rS || a >= rE) return null;
a = Math.max(a, rS);
b = Math.min(b, rE);
return b > a ? [a, b] : null;
};
const mergedBusy = (() => {
const xs = [...calA, ...calB].map(norm).filter(Boolean).sort((p, q) => p[0] - q[0] || p[1] - q[1]);
if (!xs.length) return [];
const out = [];
let [cs, ce] = xs[0];
for (let i = 1; i < xs.length; i++) {
const [s, e] = xs[i];
if (s <= ce) ce = Math.max(ce, e);
else out.push([cs, ce]), (cs = s), (ce = e);
}
out.push([cs, ce]);
return out;
})();
const free = (() => {
const out = [];
let cur = rS;
for (const [s, e] of mergedBusy) {
if (s > cur) out.push([cur, s]);
cur = Math.max(cur, e);
if (cur >= rE) break;
}
if (cur < rE) out.push([cur, rE]);
return out;
})();
const iso = ms => DateTime.fromMillis(ms, { zone: "utc" }).toISO({ suppressMilliseconds: true });
const out = [];
const dayMs = 86400000;
for (const [fs, fe] of free) {
let d0 = DateTime.fromMillis(fs, { zone: "utc" }).startOf("day").toMillis();
const d1 = DateTime.fromMillis(fe - 1, { zone: "utc" }).startOf("day").toMillis();
for (let d = d0; d <= d1; d += dayMs) {
const base = DateTime.fromMillis(d, { zone: "utc" });
const wS = base.set({ hour: ws.h, minute: ws.m, second: 0, millisecond: 0 }).toMillis();
const wE = base.set({ hour: we.h, minute: we.m, second: 0, millisecond: 0 }).toMillis();
const a = Math.max(fs, wS);
const b = Math.min(fe, wE);
for (let t = a; t + durMs <= b; t += durMs) out.push({ start: iso(t), end: iso(t + durMs) });
}
}
return out;
};
export default findAvailableSlots;
// Generation time: 32.586s
// Result: PASS

View File

@@ -1,40 +0,0 @@
async function findAvailableSlots(c1, c2, { durationMinutes: d, searchRange: { start: rs, end: re }, workHours: { start: whs, end: whe } }) {
const dayjs = (await import('https://cdn.skypack.dev/dayjs')).default;
const utc = (await import('https://cdn.skypack.dev/dayjs/plugin/utc')).default;
dayjs.extend(utc);
const to = s => dayjs.utc(s);
const busy = [...c1, ...c2].map(o => ({ s: to(o.start), e: to(o.end) })).sort((a, b) => a.s - b.s);
const merged = [];
for (const b of busy) {
if (!merged.length || b.s.isAfter(merged[merged.length - 1].e)) merged.push(b);
else if (b.e.isAfter(merged[merged.length - 1].e)) merged[merged.length - 1].e = b.e;
}
const sr = to(rs), er = to(re);
const free = [];
let cur = sr;
for (const b of merged) {
if (b.e.isAfter(cur)) {
if (b.s.isAfter(cur)) free.push({ s: cur, e: b.s });
cur = dayjs.max(cur, b.e);
}
}
if (cur.isBefore(er)) free.push({ s: cur, e: er });
const [whsh, whsm] = whs.split(':').map(Number);
const [wheh, whom] = whe.split(':').map(Number);
const slots = [];
for (let day = sr.startOf('day'); day.isBefore(er); day = day.add(1, 'day')) {
const ws = day.set('hour', whsh).set('minute', whsm);
const we = day.set('hour', wheh).set('minute', whom);
for (const f of free) {
const s = dayjs.max(f.s, ws);
const e = dayjs.min(f.e, we);
for (let t = s; !t.add(d, 'minute').isAfter(e); t = t.add(d, 'minute')) {
slots.push({ start: t.toISOString(), end: t.add(d, 'minute').toISOString() });
}
}
}
return slots;
}
export default findAvailableSlots;
// Generation time: 3.739s
// Result: FAIL

View File

@@ -1,46 +0,0 @@
const findAvailableSlots = async (cal1, cal2, { durationMinutes, searchRange, workHours }) => {
const dayjs = (await import('https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js')).default;
dayjs.extend((await import('https://cdn.jsdelivr.net/npm/dayjs@1/plugin/utc.js')).default);
const min = s => (s = s.split(':'), +s[0] * 60 + +s[1]);
const ts = s => dayjs.utc(s).valueOf();
const iso = t => new Date(t).toISOString();
const dur = durationMinutes * 60000;
const ws = min(workHours.start), we = min(workHours.end);
const rs = ts(searchRange.start), re = ts(searchRange.end);
const merged = [...cal1, ...cal2]
.map(x => ({ s: ts(x.start), e: ts(x.end) }))
.sort((a, b) => a.s - b.s)
.reduce((a, c) => {
if (a.length && c.s <= a[a.length - 1].e) a[a.length - 1].e = Math.max(a[a.length - 1].e, c.e);
else a.push(c);
return a;
}, []);
const fill = (start, end) => {
let t = start, res = [];
while (t + dur <= end) {
const sod = dayjs.utc(t).startOf('day').valueOf();
const s = sod + ws * 60000, e = sod + we * 60000;
if (t < s) t = s;
if (t >= e) { t = sod + 86400000; continue; }
if (t + dur <= e) {
if (t + dur <= end) res.push({ start: iso(t), end: iso(t + dur) }), t += dur;
else break;
} else t = sod + 86400000;
}
return res;
};
let curr = rs, slots = [];
merged.forEach(b => {
if (b.s > curr) slots.push(...fill(curr, Math.min(b.s, re)));
curr = Math.max(curr, b.e);
});
if (curr < re) slots.push(...fill(curr, re));
return slots;
};
export default findAvailableSlots;
// Generation time: 508.729s
// Result: FAIL