Docs: Update benchmark for google/gemini-3-flash-preview TEMP:0.35

This commit is contained in:
github-actions[bot]
2025-12-17 16:55:05 +00:00
parent 47c178fc67
commit 3c12fd855f
9 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
const hashPassword = async (password, salt) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm');
const enc = new TextEncoder();
const hash = await scrypt(
enc.encode(password),
enc.encode(salt),
1024,
8,
1,
32
);
return [...hash]
.map(b => b.toString(16).padStart(2, 0))
.join('');
};
export default hashPassword;
// Generation time: 12.168s
// Result: PASS

View File

@@ -0,0 +1,15 @@
async function analyzeGPS(readings, boundary) {
const turf = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const pts = readings
.filter(({ loc }) => turf.booleanPointInPolygon(loc, boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc);
return pts.length < 2
? 0
: +turf.length(turf.lineString(pts), { units: 'kilometers' }).toFixed(2);
}
export default analyzeGPS;
// Generation time: 36.478s
// Result: PASS

View File

@@ -0,0 +1,27 @@
async function findShortestPath(graph, start, end) {
const PQ = (await import('https://esm.sh/js-priority-queue')).default;
const dists = { [start]: 0 };
const pq = new PQ({ comparator: (a, b) => a.w - b.w });
pq.queue({ n: start, w: 0 });
while (pq.length) {
const { n, w } = pq.dequeue();
if (n === end) return w;
if (w > (dists[n] ?? Infinity)) continue;
for (const [m, weight] of Object.entries(graph[n] ?? {})) {
const d = w + weight;
if (d < (dists[m] ?? Infinity)) {
dists[m] = d;
pq.queue({ n: m, w: d });
}
}
}
return Infinity;
}
export default findShortestPath;
// Generation time: 20.870s
// Result: PASS

View File

@@ -0,0 +1,28 @@
export const findConvexHull = async (points) => {
const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es/+esm');
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (sorted.length < 3) return sorted;
const buildChain = (pts) => {
const hull = [];
for (const p of pts) {
while (hull.length >= 2) {
const a = hull[hull.length - 2];
const b = hull[hull.length - 1];
if ((b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x) > 0) break;
hull.pop();
}
hull.push(p);
}
return hull;
};
const lower = buildChain(sorted);
const upper = buildChain([...sorted].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
};
export default findConvexHull;
// Generation time: 17.558s
// Result: PASS

View File

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

View File

@@ -0,0 +1,11 @@
const parseMarkdown = async (markdown = '') => {
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@12.0.1/lib/marked.esm.js');
return marked.parse(markdown, {
gfm: true,
breaks: true
});
};
export default parseMarkdown;
// Generation time: 23.564s
// Result: PASS

View File

@@ -0,0 +1,33 @@
export const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
const [{ default: Papa }, { default: _ }] = await Promise.all([
import('https://cdn.skypack.dev/papaparse'),
import('https://cdn.skypack.dev/lodash')
]);
const { data } = Papa.parse(csv, {
header: true,
skipEmptyLines: 'greedy'
});
return _.chain(data)
.filter(row => row[filterColumn] == filterValue)
.groupBy(groupBy)
.map((groupRows, groupKey) => {
const numbers = groupRows.map(r => Number(r[aggregateColumn]) || 0);
const sum = _.sum(numbers);
const result = {
sum,
avg: sum / numbers.length,
count: numbers.length
}[operation];
return {
[groupBy]: groupKey,
result
};
})
.value();
};
export default processCSV;
// Generation time: 18.916s
// Result: PASS

View File

@@ -0,0 +1,23 @@
export const validateJSON = async (data, schema) => {
const Ajv = (await import('https://cdn.jsdelivr.net/npm/ajv@8.17.1/+esm')).default;
const ajv = new Ajv({
allErrors: true,
strict: false,
useDefaults: true
});
const validate = ajv.compile(schema);
const isValid = validate(data);
return {
valid: isValid,
errors: isValid ? [] : validate.errors.map(err => ({
path: err.instancePath || 'root',
message: err.message,
params: err.params
}))
};
};
export default validateJSON;
// Generation time: 10.003s
// Result: PASS

View File

@@ -0,0 +1,33 @@
export async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) {
const d3 = await import("https://cdn.skypack.dev/d3@7");
const data = [];
let ema;
for await (const { timestamp, value } of asyncIterable) {
ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
}
if (!data.length) return { data, path: "" };
const x = d3.scaleLinear()
.domain([data[0].timestamp, data.at(-1).timestamp])
.range([0, width]);
const y = d3.scaleLinear()
.domain(yDomain)
.range([height, 0]);
const lineGenerator = d3.line()
.x(d => x(d.timestamp))
.y(d => y(d.ema));
return {
data,
path: lineGenerator(data)
};
}
export default createStreamVisualizer;
// Generation time: 16.044s
// Result: PASS