Docs: Update benchmark for deepseek/deepseek-v4-pro

This commit is contained in:
github-actions[bot]
2026-04-25 02:00:44 +00:00
parent bca9ba076b
commit d1bb37cfb3
12 changed files with 364 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
async function hashPassword(p, s) {
const e = new TextEncoder;
const { default: scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm');
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
return [...h].map(b => (b < 16 ? '0' : '') + b.toString(16)).join('');
}
export default hashPassword;
// Generation time: 58.113s
// Result: FAIL

View File

@@ -0,0 +1,17 @@
async function analyzeGPS(r, e) {
try {
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf@7.0.0/dist/turf.min.mjs');
const v = r.filter(({ loc: a }) => t.booleanPointInPolygon(t.point(a), e));
if (v.length < 2) return 0;
v.sort((a, b) => a.ts - b.ts);
const c = v.map(a => a.loc);
const l = t.lineString(c);
const n = t.length(l, { units: 'kilometers' });
return Math.round(n * 100) / 100;
} catch {
return 0;
}
}
export default analyzeGPS;
// Generation time: 59.388s
// Result: FAIL

View File

@@ -0,0 +1,46 @@
async function computeMST(t) {
const [{ default: parse }, { Heap }, { default: table }] = await Promise.all([
import('https://cdn.jsdelivr.net/npm/smol-toml@1.2.0/dist/index.mjs'),
import('https://cdn.jsdelivr.net/npm/mnemonist@0.39.6/heap.mjs'),
import('https://cdn.jsdelivr.net/npm/text-table@0.2.0/+esm')
])
const c = parse(t)
const edges = c.edges
const nodes = new Set
edges.forEach(({ from, to }) => { nodes.add(from); nodes.add(to) })
const parent = {}
const rank = {}
nodes.forEach(n => { parent[n] = n; rank[n] = 0 })
const find = x => {
while (parent[x] !== x) {
parent[x] = parent[parent[x]]
x = parent[x]
}
return x
}
const union = (x, y) => {
const rx = find(x)
const ry = find(y)
if (rx === ry) return !1
if (rank[rx] < rank[ry]) parent[rx] = ry
else if (rank[rx] > rank[ry]) parent[ry] = rx
else { parent[ry] = rx; rank[rx]++ }
return !0
}
const heap = new Heap((a, b) => a.weight > b.weight)
edges.forEach(e => heap.push(e))
const mst = []
const target = nodes.size - 1
let total = 0
while (heap.size && mst.length < target) {
const e = heap.pop()
if (union(e.from, e.to)) {
mst.push([e.from, e.to, String(e.weight)])
total += e.weight
}
}
return { table: table([['From', 'To', 'Weight'], ...mst]), totalWeight: total }
}
export default computeMST;
// Generation time: 116.739s
// Result: FAIL

View File

@@ -0,0 +1,24 @@
async function findShortestPath(g,s,e){
const {default:P}=await import('https://esm.sh/js-priority-queue');
const d={};
for(let k in g)d[k]=Infinity;
d[s]=0;
const q=new P({comparator:(a,b)=>a.w-b.w});
q.queue({n:s,w:0});
while(q.length){
const {n,w}=q.dequeue();
if(n===e)return w;
if(w>d[n])continue;
for(const t in g[n]){
const w2=w+g[n][t];
if(w2<d[t]){
d[t]=w2;
q.queue({n:t,w:w2});
}
}
}
return Infinity
}
export default findShortestPath;
// Generation time: 45.490s
// Result: PASS

View File

@@ -0,0 +1,25 @@
const findConvexHull = async (points) => {
const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js');
const pts = _.sortBy(_.uniqWith(points, (a, b) => a.x === b.x && a.y === b.y), ['x', 'y']);
const n = pts.length;
if (n <= 2) return pts;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const lower = [];
for (let i = 0; i < n; i++) {
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], pts[i]) <= 0)
lower.pop();
lower.push(pts[i]);
}
const upper = [];
for (let i = n - 1; i >= 0; i--) {
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], pts[i]) <= 0)
upper.pop();
upper.push(pts[i]);
}
lower.pop();
upper.pop();
return lower.concat(upper);
};
export default findConvexHull;
// Generation time: 21.237s
// Result: FAIL

View File

@@ -0,0 +1,42 @@
async function analyzeSignal(y) {
const [Y, M, Nd, Fft, P] = await Promise.all([
import('https://esm.run/js-yaml@4.1.0').then(m => m.default),
import('https://esm.run/mathjs@11.8.0').then(m => m.default),
import('https://esm.run/ndarray@1.0.19').then(m => m.default),
import('https://esm.run/ndarray-fft@1.0.3').then(m => m.default),
import('https://esm.run/dompurify@3.0.5').then(m => m.default)
]);
const cfg = Y.load(y),
sr = cfg.sampleRate,
d = cfg.duration,
comps = cfg.components,
N = sr * d,
sig = Array.from({ length: N }, (_, i) => {
const t = i / sr;
return comps.reduce((s, c) => s + c.amplitude * M.sin(2 * M.pi * c.frequency * t), 0);
}),
real = Nd(new Float64Array(sig), [N]),
imag = Nd(new Float64Array(N), [N]);
Fft(1, real, imag);
const half = N / 2,
peaks = [];
for (let k = 0; k <= half; k++) {
const re = real.get(k),
im = imag.get(k),
mag = M.sqrt(re * re + im * im) / half;
if (mag > 0.1) peaks.push({ f: Math.round(k * sr / N), m: Math.round(mag * 1e2) / 1e2 });
}
peaks.sort((a, b) => b.m - a.m);
let h = '<table><tr><th>Frequency (Hz)</th><th>Magnitude</th></tr>';
for (const p of peaks) h += `<tr><td>${p.f}</td><td>${p.m}</td></tr>`;
h += '</table>';
const sH = P.sanitize(h);
return {
peaks: peaks.map(p => ({ frequencyHz: p.f, magnitude: p.m })),
html: sH,
signalLength: N
};
}
export default analyzeSignal;
// Generation time: 102.963s
// Result: FAIL

View File

@@ -0,0 +1,48 @@
async function hexchain(t){
const [T,S,SS,A,B,P]=await Promise.all([
import('smol-toml'),
import('seedrandom'),
import('simple-statistics'),
import('ajv'),
import('text-table'),
import('dompurify')
]);
const c=T.parse(t);
const Ajv=A.default||A,ajv=new Ajv;
const schema={
type:'object',
required:['seed','count','label'],
properties:{
seed:{type:'string'},
count:{type:'integer',minimum:1,maximum:10000},
label:{type:'string',minLength:1}
}
};
const v=ajv.compile(schema);
if(!v(c))return{valid:false,errors:ajv.errorsText(v.errors)};
const rng=new (S.default||S)(c.seed),
arr=Array.from({length:c.count},rng);
const ss=SS.default||SS;
let m=ss.mean(arr),d=ss.standardDeviation(arr),md=ss.median(arr);
m=+m.toFixed(6);
d=+d.toFixed(6);
md=+md.toFixed(6);
const tbl=(B.default||B)([
['Stat','Value'],
['mean',String(m)],
['stddev',String(d)],
['median',String(md)]
]);
const purify=P.default||P,
h=purify.sanitize(`<pre class="stats">${tbl}</pre>`);
return{
valid:true,
label:c.label,
stats:{mean:m,stddev:d,median:md},
table:h,
count:c.count
};
}
export default hexchain;
// Generation time: 121.732s
// Result: FAIL

View File

@@ -0,0 +1,7 @@
async function parseMarkdown(m){
const{marked}=await import('//cdn.jsdelivr.net/npm/marked@4/lib/marked.esm.js')
return marked(m)
}
export default parseMarkdown;
// Generation time: 44.452s
// Result: FAIL

View File

@@ -0,0 +1,22 @@
async function processCSV(csv, c) {
const { default: P } = await import(
'https://cdn.jsdelivr.net/npm/papaparse@5/+esm'
);
const { filterColumn: f, filterValue: v, groupBy: g, aggregateColumn: a, operation: o } = c;
const rows = P.parse(csv, { header: true, skipEmptyLines: true }).data;
const filtered = rows.filter((r) => r[f] == v);
const groups = {};
for (const r of filtered) {
const k = r[g];
groups[k] = groups[k] || { n: 0, s: 0 };
groups[k].n++;
groups[k].s += +r[a] || 0;
}
return Object.entries(groups).map(([k, { n, s }]) => ({
[g]: k,
result: o === 'sum' ? s : o === 'avg' ? s / n : n,
}));
}
export default processCSV;
// Generation time: 75.337s
// Result: PASS

View File

@@ -0,0 +1,82 @@
let _dayjsPromise;
const loadDayjs = () => _dayjsPromise || (_dayjsPromise = (async () => {
const dayjs = (await import('https://cdn.skypack.dev/dayjs@1')).default;
const utc = (await import('https://cdn.skypack.dev/dayjs@1/plugin/utc')).default;
dayjs.extend(utc);
return dayjs;
})());
async function findAvailableSlots(cal1, cal2, constraints) {
const dayjs = await loadDayjs();
const { durationMinutes, searchRange, workHours } = constraints;
const rStart = dayjs.utc(searchRange.start);
const rEnd = dayjs.utc(searchRange.end);
const [wSh, wSm] = workHours.start.split(':').map(Number);
const [wEh, wEm] = workHours.end.split(':').map(Number);
// Merge all busy slots
const allBusy = [...cal1, ...cal2]
.map(s => ({ start: dayjs.utc(s.start), end: dayjs.utc(s.end) }))
.filter(s => s.start.isValid() && s.end.isValid() && s.start.isBefore(s.end));
allBusy.sort((a, b) => a.start.valueOf() - b.start.valueOf());
const merged = [];
for (const busy of allBusy) {
if (!merged.length || busy.start.isAfter(merged[merged.length - 1].end)) {
merged.push({ start: busy.start, end: busy.end });
} else if (busy.end.isAfter(merged[merged.length - 1].end)) {
merged[merged.length - 1].end = busy.end;
}
}
const result = [];
let day = rStart.startOf('day');
const endDay = rEnd.startOf('day');
while (day.isBefore(endDay) || day.isSame(endDay, 'day')) {
const workStart = day.hour(wSh).minute(wSm).second(0);
const workEnd = day.hour(wEh).minute(wEm).second(0);
const dStart = dayjs.max(workStart, rStart);
const dEnd = dayjs.min(workEnd, rEnd);
if (dStart.isBefore(dEnd)) {
let gapStart = dStart;
for (const busy of merged) {
if (busy.end.isBefore(dStart) || busy.start.isAfter(dEnd)) continue;
if (busy.start.isAfter(gapStart)) {
const freeStart = gapStart;
const freeEnd = busy.start;
let slotStart = freeStart;
while (slotStart.add(durationMinutes, 'minute').isBefore(freeEnd) || slotStart.add(durationMinutes, 'minute').isSame(freeEnd)) {
const slotEnd = slotStart.add(durationMinutes, 'minute');
if (slotEnd.isAfter(freeEnd)) break;
result.push({ start: slotStart.toISOString(), end: slotEnd.toISOString() });
slotStart = slotEnd;
}
gapStart = busy.end;
} else if (busy.end.isAfter(gapStart)) {
gapStart = busy.end;
}
}
if (gapStart.isBefore(dEnd)) {
let slotStart = gapStart;
while (slotStart.add(durationMinutes, 'minute').isBefore(dEnd) || slotStart.add(durationMinutes, 'minute').isSame(dEnd)) {
const slotEnd = slotStart.add(durationMinutes, 'minute');
if (slotEnd.isAfter(dEnd)) break;
result.push({ start: slotStart.toISOString(), end: slotEnd.toISOString() });
slotStart = slotEnd;
}
}
}
day = day.add(1, 'day');
}
return result.sort((a, b) => a.start.localeCompare(b.start));
}
export default findAvailableSlots;
// Generation time: 135.095s
// Result: FAIL

View File

@@ -0,0 +1,19 @@
let _p
async function validateJSON(d, s) {
if (!_p) _p = (async () => {
const {default: A} = await import('https://cdn.jsdelivr.net/npm/ajv@8.17.1/dist/ajv2020.esm.js')
return new A({allErrors: 1})
})()
try {
const a = await _p
const v = a.validate(s, d)
return v
? {valid: 1, errors: []}
: {valid: 0, errors: a.errors.map(e => `${e.instancePath||'/'} ${e.message}`.trim())}
} catch (e) {
return {valid: 0, errors: [e.message]}
}
}
export default validateJSON;
// Generation time: 54.656s
// Result: FAIL

View File

@@ -0,0 +1,23 @@
const createStreamVisualizer = async (feed, { p = 1000, a = .25, w, h, y }) => {
const d3 = (await import('https://esm.sh/d3@7')).default
const data = []
for await (const { timestamp: t, value: v } of feed) {
const e = data.length ? a * v + (1 - a) * data[data.length - 1].ema : v
data.push({ timestamp: t, value: v, ema: e })
if (data.length > p) data.shift()
}
if (!data.length) return { data: [], path: '' }
const x = d3.scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, w])
const y = d3.scaleLinear()
.domain(y)
.range([h, 0])
const line = d3.line()
.x(d => x(d.timestamp))
.y(d => y(d.ema))
return { data, path: line(data) }
}
export default createStreamVisualizer;
// Generation time: 71.592s
// Result: FAIL