Docs: Update benchmark for google/gemini-3.1-pro-preview

This commit is contained in:
github-actions[bot]
2026-02-19 16:23:35 +00:00
parent f3e94e99ff
commit 75b92c832f
12 changed files with 219 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
export async function hashPassword(p, s) {
const { scrypt } = await import('https://esm.sh/scrypt-js');
const e = new TextEncoder();
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
return [...h].map(b => b.toString(16).padStart(2, '0')).join('');
}
export default hashPassword;
// Generation time: 17.304s
// Result: PASS

View File

@@ -0,0 +1,12 @@
const analyzeGPS = async (r, b) => {
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const v = r
.filter(p => t.booleanPointInPolygon(t.point(p.loc), b, { ignoreBoundary: true }))
.sort((x, y) => x.ts - y.ts);
return v.length < 2 ? 0 : +t.length(t.lineString(v.map(p => p.loc))).toFixed(2);
};
export default analyzeGPS;
// Generation time: 23.653s
// Result: PASS

View File

@@ -0,0 +1,33 @@
async function computeMST(str) {
const [T, M, X] = await Promise.all(
['smol-toml', 'mnemonist', 'text-table'].map(m => import(`https://esm.sh/${m}`))
);
const Q = new M.Heap((a, b) => a.weight - b.weight);
const S = new Set(), p = {}, r = {};
for (const e of T.parse(str).edges ?? []) {
Q.push(e);
S.add(e.from).add(e.to);
}
S.forEach(x => (p[x] = x, r[x] = 0));
const f = x => p[x] === x ? x : (p[x] = f(p[x]));
const A = [['From', 'To', 'Weight']];
let W = 0, c = 0, L = S.size - 1;
while (Q.size && c < L) {
const e = Q.pop(), u = f(e.from), v = f(e.to);
if (u !== v) {
r[u] < r[v] ? p[u] = v : r[u] > r[v] ? p[v] = u : (p[v] = u, r[u]++);
A.push([e.from, e.to, `${e.weight}`]);
W += e.weight;
c++;
}
}
return { table: X.default(A), totalWeight: W };
}
export default computeMST;
// Generation time: 32.324s
// Result: PASS

View File

@@ -0,0 +1,27 @@
export const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import("https://esm.sh/js-priority-queue");
const q = new PQ({ comparator: (a, b) => a[1] - b[1] });
const d = { [s]: 0 };
q.queue([s, 0]);
while (q.length) {
const [u, w] = q.dequeue();
if (u === e) return w;
if (w > d[u]) continue;
for (const [v, c] of Object.entries(g[u] ?? {})) {
const a = w + c;
if (a < (d[v] ?? Infinity)) {
d[v] = a;
q.queue([v, a]);
}
}
}
return Infinity;
};
export default findShortestPath;
// Generation time: 19.792s
// Result: PASS

View File

@@ -0,0 +1,17 @@
const findConvexHull = async p => {
const { uniqWith, isEqual, sortBy } = await import('https://esm.sh/lodash-es');
const s = sortBy(uniqWith(p, isEqual), ['x', 'y']);
if (s.length < 3) return s;
const cw = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x) <= 0;
const fn = a => a.reduce((h, pt) => {
while (h.length > 1 && cw(h.at(-2), h.at(-1), pt)) h.pop();
return h.push(pt), h;
}, []);
return [...fn(s).slice(0, -1), ...fn([...s].reverse()).slice(0, -1)];
};
export default findConvexHull;
// Generation time: 39.797s
// Result: PASS

View File

@@ -0,0 +1,9 @@
export const findLISLength = async a => {
const { bisectLeft } = await import("https://esm.sh/d3-array");
const s = [];
for (const x of a) s[bisectLeft(s, x)] = x;
return s.length;
};
export default findLISLength;
// Generation time: 15.537s
// Result: PASS

View File

@@ -0,0 +1,7 @@
const renderTemplate = async (template, data) => {
const { default: hbs } = await import("https://esm.sh/handlebars");
return hbs.compile(template)(data);
};
export default renderTemplate;
// Generation time: 14.818s
// Result: PASS

View File

@@ -0,0 +1,7 @@
const parseMarkdown = async m => {
const { parse } = await import('https://cdn.jsdelivr.net/npm/marked/+esm');
return parse(m);
};
export default parseMarkdown;
// Generation time: 23.960s
// Result: PASS

View File

@@ -0,0 +1,13 @@
export const processCSV = async (c, { filterColumn: f, filterValue: v, groupBy: g, aggregateColumn: a, operation: o }) => {
const { default: P } = await import('https://esm.sh/papaparse');
return [...P.parse(c, { header: true, skipEmptyLines: true }).data
.filter(r => r[f] == v)
.reduce((m, r) => {
const k = r[g], n = +r[a] || 0, x = m.get(k) || { s: 0, c: 0 };
return m.set(k, { s: x.s + n, c: x.c + 1 });
}, new Map())]
.map(([k, x]) => ({ [g]: k, result: o == 'count' ? x.c : o == 'sum' ? x.s : x.s / x.c }));
};
export default processCSV;
// Generation time: 50.753s
// Result: PASS

View File

@@ -0,0 +1,43 @@
const findAvailableSlots = async (c1, c2, { durationMinutes: dM, searchRange: sR, workHours: wH }) => {
const [{ default: D }, { default: U }] = await Promise.all([
import('https://esm.sh/dayjs'),
import('https://esm.sh/dayjs/plugin/utc')
]);
D.extend(U);
let m = [], f = [], a = [], dm = dM * 6e4,
c = D.utc(sR.start).valueOf(),
e = D.utc(sR.end).valueOf(),
[sH, sM] = wH.start.split(':'),
[eH, eM] = wH.end.split(':');
[...c1, ...c2]
.map(x => ({ s: D.utc(x.start).valueOf(), e: D.utc(x.end).valueOf() }))
.sort((x, y) => x.s - y.s)
.forEach(x => {
let l = m[m.length - 1];
!l || l.e < x.s ? m.push(x) : l.e = Math.max(l.e, x.e);
});
m.forEach(x => {
if (x.s > c && x.s <= e) f.push({ s: c, e: Math.min(x.s, e) });
c = Math.max(c, x.e);
});
if (c < e) f.push({ s: c, e });
f.forEach(x => {
for (let p = x.s; p + dm <= x.e; p += dm) {
let t = D.utc(p),
w1 = t.clone().hour(sH).minute(sM).second(0).millisecond(0).valueOf(),
w2 = t.clone().hour(eH).minute(eM).second(0).millisecond(0).valueOf();
if (p >= w1 && p + dm <= w2) {
a.push({ start: t.toISOString(), end: D.utc(p + dm).toISOString() });
}
}
});
return a;
};
export default findAvailableSlots;
// Generation time: 39.017s
// Result: PASS

View File

@@ -0,0 +1,13 @@
export const validateJSON = async (d, s) => {
const { default: A } = await import("https://esm.sh/ajv@8");
const v = new A({ allErrors: true }).compile(s);
const k = v(d);
return {
valid: k,
errors: k ? [] : v.errors.map(e => `${e.instancePath || "/"} ${e.message}`.trim())
};
};
export default validateJSON;
// Generation time: 16.896s
// Result: PASS

View File

@@ -0,0 +1,29 @@
export const createStreamVisualizer = async (
stream,
{ maxPoints, alpha, width, height, yDomain }
) => {
const { scaleLinear, line } = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
const data = [];
let ema;
for await (const { timestamp, value } of stream) {
ema = data.length ? alpha * value + (1 - alpha) * ema : value;
data.push({ timestamp, value, ema });
data.length > maxPoints && data.shift();
}
if (!data.length) return { data, path: "" };
const x = scaleLinear([data[0].timestamp, data.at(-1).timestamp], [0, width]);
const y = scaleLinear(yDomain, [height, 0]);
return {
data,
path: line()
.x(d => x(d.timestamp))
.y(d => y(d.ema))(data)
};
};
export default createStreamVisualizer;
// Generation time: 42.202s
// Result: PASS