Docs: Update benchmark for deepseek/deepseek-v3.2

This commit is contained in:
github-actions[bot]
2025-12-01 15:02:03 +00:00
parent c8893a805f
commit 0b47c76f63
11 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
const hashPassword = async (password, salt) => {
const { scrypt } = await import('https://cdn.skypack.dev/scrypt-js');
const encoder = new TextEncoder();
const passwordBytes = encoder.encode(password);
const saltBytes = encoder.encode(salt);
const hashBytes = await scrypt(passwordBytes, saltBytes, 1024, 8, 1, 32);
return Array.from(hashBytes).map(b => b.toString(16).padStart(2, '0')).join('');
};
export default hashPassword;
// Generation time: 5.832s
// Result: PASS

View File

@@ -0,0 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const turf = await import('https://cdn.skypack.dev/@turf/turf');
const inside = readings.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary));
if (inside.length < 2) return 0;
const sorted = inside.sort((a, b) => a.ts - b.ts);
const line = turf.lineString(sorted.map(r => r.loc));
const length = turf.length(line, { units: 'kilometers' });
return Math.round(length * 100) / 100;
};
export default analyzeGPS;
// Generation time: 5.688s
// Result: PASS

View File

@@ -0,0 +1,33 @@
const findShortestPath = async (graph, start, end) => {
const { PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@latest/+esm');
const distances = {};
const previous = {};
const visited = new Set();
const queue = new PriorityQueue({ comparator: (a, b) => a.distance - b.distance });
Object.keys(graph).forEach(node => distances[node] = Infinity);
distances[start] = 0;
queue.queue({ node: start, distance: 0 });
while (queue.length) {
const { node: current } = queue.dequeue();
if (visited.has(current)) continue;
visited.add(current);
if (current === end) break;
for (const neighbor in graph[current]) {
const weight = graph[current][neighbor];
const newDist = distances[current] + weight;
if (newDist < distances[neighbor]) {
distances[neighbor] = newDist;
previous[neighbor] = current;
queue.queue({ node: neighbor, distance: newDist });
}
}
}
return distances[end] === undefined ? Infinity : distances[end];
};
export default findShortestPath;
// Generation time: 9.823s
// Result: FAIL

View File

@@ -0,0 +1,21 @@
const findConvexHull = async (points) => {
const _ = await import('https://cdn.skypack.dev/lodash');
const sorted = _.uniqBy(points, p => `${p.x},${p.y}`).sort((a, b) => a.x - b.x || a.y - b.y);
if (sorted.length < 3) return sorted;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const buildHull = (pts) => {
const hull = [];
for (const p of pts) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) hull.pop();
hull.push(p);
}
hull.pop();
return hull;
};
const lower = buildHull(sorted);
const upper = buildHull(sorted.reverse());
return lower.concat(upper);
};
export default findConvexHull;
// Generation time: 9.132s
// Result: PASS

View File

@@ -0,0 +1,12 @@
async function findLISLength(arr) {
const d3 = await import('https://esm.sh/d3-array@3.2.4');
const tails = [];
for (const num of arr) {
const i = d3.bisectLeft(tails, num);
tails[i] = num;
}
return tails.length;
}
export default findLISLength;
// Generation time: 3.865s
// Result: PASS

View File

@@ -0,0 +1,8 @@
const renderTemplate = async (templateString, data) => {
const { default: Handlebars } = await import('https://cdn.skypack.dev/handlebars');
const template = Handlebars.compile(templateString);
return template(data);
};
export default renderTemplate;
// Generation time: 3.202s
// Result: PASS

View File

@@ -0,0 +1,9 @@
async function parseMarkdown(markdown) {
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js');
const { gfmHeadingId } = await import('https://cdn.jsdelivr.net/npm/marked-gfm-heading-id/+esm');
marked.use(gfmHeadingId());
return marked.parse(markdown, { async: false, gfm: true, breaks: true });
}
export default parseMarkdown;
// Generation time: 4.398s
// Result: PASS

View File

@@ -0,0 +1,30 @@
async function processCSV(csv, config) {
const { Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
const { groupBy, sumBy, meanBy } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm');
const parsed = Papa.parse(csv, { header: true, skipEmptyLines: true });
const rows = parsed.data.filter(r => r[config.filterColumn] == config.filterValue);
const numericRows = rows.map(r => ({
...r,
[config.aggregateColumn]: Number(r[config.aggregateColumn]) || 0
}));
const grouped = groupBy(numericRows, config.groupBy);
const result = Object.entries(grouped).map(([key, group]) => {
let val;
if (config.operation === 'sum') {
val = sumBy(group, config.aggregateColumn);
} else if (config.operation === 'avg') {
val = meanBy(group, config.aggregateColumn);
} else {
val = group.length;
}
return { [config.groupBy]: key, result: val };
});
return result;
}
export default processCSV;
// Generation time: 10.647s
// Result: FAIL

View File

@@ -0,0 +1,52 @@
const findAvailableSlots = async (calendar1, calendar2, constraints) => {
const { DateTime, Interval } = await import('https://cdn.jsdelivr.net/npm/luxon@3.4.4/+esm');
const parse = s => DateTime.fromISO(s, { zone: 'utc' });
const workStart = constraints.workHours.start;
const workEnd = constraints.workHours.end;
const rangeStart = parse(constraints.searchRange.start);
const rangeEnd = parse(constraints.searchRange.end);
const duration = constraints.durationMinutes;
const allBusy = [...calendar1, ...calendar2]
.map(b => Interval.fromDateTimes(parse(b.start), parse(b.end)))
.sort((a, b) => a.s - b.s);
const merged = [];
allBusy.forEach(busy => {
const last = merged[merged.length - 1];
last && last.overlaps(busy) || last?.abutsStart(busy) ?
merged[merged.length - 1] = last.union(busy) : merged.push(busy);
});
const free = [];
let current = rangeStart;
merged.forEach(busy => {
if (current < busy.s) free.push(Interval.fromDateTimes(current, busy.s));
current = busy.e > current ? busy.e : current;
});
if (current < rangeEnd) free.push(Interval.fromDateTimes(current, rangeEnd));
const slots = [];
free.forEach(interval => {
let slotStart = interval.s;
const workStartToday = slotStart.set({ hour: workStart.slice(0, 2), minute: workStart.slice(3), second: 0, millisecond: 0 });
const workEndToday = slotStart.set({ hour: workEnd.slice(0, 2), minute: workEnd.slice(3), second: 0, millisecond: 0 });
const workInterval = Interval.fromDateTimes(workStartToday, workEndToday);
const available = interval.intersection(workInterval);
if (available) {
let start = available.s > slotStart ? available.s : slotStart;
while (start.plus({ minutes: duration }) <= available.e && start.plus({ minutes: duration }) <= rangeEnd) {
const end = start.plus({ minutes: duration });
slots.push({ start: start.toISO(), end: end.toISO() });
start = end;
}
}
});
return slots;
};
export default findAvailableSlots;
// Generation time: 19.693s
// Result: PASS

View File

@@ -0,0 +1,13 @@
const validateJSON = async (json, schema) => {
const { default: Ajv } = await import('https://cdn.skypack.dev/ajv@8.12.0');
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
const valid = validate(json);
return {
valid,
errors: valid ? [] : validate.errors.map(e => `${e.instancePath} ${e.message}`)
};
};
export default validateJSON;
// Generation time: 4.839s
// Result: PASS

View File

@@ -0,0 +1,24 @@
const createStreamVisualizer = async (asyncIterable, options) => {
const { maxPoints = 100, alpha = 0.1, width = 800, height = 400, yDomain = [0, 100] } = options;
const data = [];
let ema = null;
let firstTimestamp = null;
for await (const { timestamp, value } of asyncIterable) {
ema = ema === null ? value : alpha * value + (1 - alpha) * ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
if (firstTimestamp === null) firstTimestamp = timestamp;
}
const d3 = await import('https://esm.sh/d3@7');
const xScale = d3.scaleLinear().domain([firstTimestamp, data[data.length - 1].timestamp]).range([0, width]);
const yScale = d3.scaleLinear().domain(yDomain).range([height, 0]);
const line = d3.line().x(d => xScale(d.timestamp)).y(d => yScale(d.ema));
const path = line(data);
return { data, path };
};
export default createStreamVisualizer;
// Generation time: 9.968s
// Result: PASS