Docs: Update Gemini benchmark results

This commit is contained in:
github-actions[bot]
2025-11-18 22:04:41 +00:00
parent 31a18dd4ee
commit 33b8150958
220 changed files with 3259 additions and 1494 deletions

View File

@@ -1,49 +1,33 @@
const findAvailableSlots = async (calendarA, calendarB, constraints) => {
const { default: d } = await import('https://esm.sh/dayjs@1.11.10');
const { default: u } = await import('https://esm.sh/dayjs@1.11.10/plugin/utc');
d.extend(u);
const findAvailableSlots = async (calA, calB, { durationMinutes: dur, searchRange: rng, workHours: wh }) => {
const { addMinutes: add, parseISO: prs, isBefore: isB, isAfter: isA, isEqual: isE } = await import('https://cdn.jsdelivr.net/npm/date-fns@2.30.0/esm/index.js');
const [rS, rE] = [prs(rng.start), prs(rng.end)];
const busy = [...calA, ...calB]
.map(x => ({ s: prs(x.start), e: prs(x.end) }))
.filter(x => isB(x.s, rE) && isA(x.e, rS))
.sort((a, b) => a.s - b.s);
const D = d.utc;
const ms = constraints.durationMinutes * 60000;
const rangeS = D(constraints.searchRange.start);
const rangeE = D(constraints.searchRange.end);
const [wS_H, wS_M] = constraints.workHours.start.split(':').map(Number);
const [wE_H, wE_M] = constraints.workHours.end.split(':').map(Number);
let ptr = rS, res = [];
const [wsH, wsM] = wh.start.split(':'), [weH, weM] = wh.end.split(':');
const busy = [...calendarA, ...calendarB]
.map(x => ({ s: D(x.start).valueOf(), e: D(x.end).valueOf() }))
.sort((a, b) => a.s - b.s)
.reduce((acc, c) => {
const l = acc[acc.length - 1];
if (l && c.s < l.e) l.e = Math.max(l.e, c.e);
else acc.push(c);
return acc;
}, []);
for (const b of [...busy, { s: rE, e: rE }]) {
if (isA(b.s, ptr)) {
let cur = ptr;
while (true) {
const nxt = add(cur, dur);
if (isA(nxt, b.s)) break;
const uDay = new Date(Date.UTC(cur.getUTCFullYear(), cur.getUTCMonth(), cur.getUTCDate()));
const wS = add(uDay, wsH * 60 + +wsM), wE = add(uDay, weH * 60 + +weM);
const slots = [];
let curr = rangeS.startOf('day');
const endDay = rangeE.endOf('day');
while (curr.isBefore(endDay)) {
let sTime = curr.hour(wS_H).minute(wS_M).second(0).millisecond(0);
let eTime = curr.hour(wE_H).minute(wE_M).second(0).millisecond(0);
const sVal = Math.max(sTime.valueOf(), rangeS.valueOf());
const eVal = Math.min(eTime.valueOf(), rangeE.valueOf());
let ptr = sVal;
while (ptr + ms <= eVal) {
const conflict = busy.find(b => b.s < ptr + ms && b.e > ptr);
if (conflict) {
ptr = conflict.e;
} else {
slots.push({ start: D(ptr).format(), end: D(ptr + ms).format() });
ptr += ms;
if ((isA(cur, wS) || isE(cur, wS)) && (isB(nxt, wE) || isE(nxt, wE))) {
res.push({ start: cur.toISOString(), end: nxt.toISOString() });
}
cur = nxt;
}
}
curr = curr.add(1, 'day');
ptr = isA(b.e, ptr) ? b.e : ptr;
}
return slots;
return res;
};
export default findAvailableSlots;