Docs: Update benchmark for openrouter/aurora-alpha

This commit is contained in:
github-actions[bot]
2026-02-09 18:45:17 +00:00
parent bb8553e8b0
commit 936cb91590
12 changed files with 245 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
async function hashPassword(p, s) {
const e = new TextEncoder(),
pU = e.encode(p),
sU = e.encode(s),
{ scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/dist/scrypt.esm.js');
const dk = await scrypt(pU, sU, 1024, 8, 1, 32);
let h = '';
for (let i = 0; i < dk.length; i++) h += dk[i].toString(16).padStart(2, '0');
return h;
}
export default hashPassword;
// Generation time: 1.126s
// Result: FAIL

View File

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

View File

@@ -0,0 +1,45 @@
async function computeMST(tomlStr) {
const [{ parse }, { Heap }, table] = await Promise.all([
import('https://unpkg.com/smol-toml@latest/dist/smol-toml.esm.js'),
import('https://unpkg.com/mnemonist@latest/dist/mnemonist.esm.js'),
import('https://unpkg.com/text-table@latest/index.js')
])
const { edges = [] } = parse(tomlStr)
const heap = new Heap((a, b) => a.weight - b.weight)
const nodes = new Set()
for (const e of edges) {
heap.push(e)
nodes.add(e.from)
nodes.add(e.to)
}
const parent = {}
const rank = {}
for (const n of nodes) {
parent[n] = n
rank[n] = 0
}
const find = x => (parent[x] === x ? x : (parent[x] = find(parent[x])))
const union = (a, b) => {
a = find(a)
b = find(b)
if (a === b) return false
if (rank[a] < rank[b]) [a, b] = [b, a]
parent[b] = a
if (rank[a] === rank[b]) rank[a]++
return true
}
const mst = []
let total = 0
while (mst.length < nodes.size - 1 && heap.size > 0) {
const e = heap.pop()
if (union(e.from, e.to)) {
mst.push([e.from, e.to, String(e.weight)])
total += e.weight
}
}
const tbl = table([['From', 'To', 'Weight'], ...mst])
return { table: tbl, totalWeight: total }
}
export default computeMST;
// Generation time: 1.686s
// Result: FAIL

View File

@@ -0,0 +1,26 @@
async function findShortestPath(g, s, t) {
if (!(s in g) || !(t in g)) return Infinity;
const { PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
const d = {}, v = new Set();
for (const n in g) d[n] = Infinity;
d[s] = 0;
const q = new PriorityQueue({ comparator: (a, b) => a[0] - b[0] });
q.queue([0, s]);
while (q.length) {
const [dist, u] = q.dequeue();
if (v.has(u)) continue;
if (u === t) return dist;
v.add(u);
for (const [nbr, w] of Object.entries(g[u])) {
const nd = dist + w;
if (nd < d[nbr]) {
d[nbr] = nd;
q.queue([nd, nbr]);
}
}
}
return Infinity;
}
export default findShortestPath;
// Generation time: 2.281s
// Result: FAIL

View File

@@ -0,0 +1,21 @@
async function findConvexHull(p){
const _=await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm');
const s=_.sortBy(_.uniqBy(p,q=>q.x+','+q.y),['x','y']);
const c=(o,a,b)=> (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
const L=[];
for(const q of s){
while(L.length>1 && c(L[L.length-2],L[L.length-1],q)<=0) L.pop();
L.push(q);
}
const U=[];
for(let i=s.length-1;i>=0;i--){
const q=s[i];
while(U.length>1 && c(U[U.length-2],U[U.length-1],q)<=0) U.pop();
U.push(q);
}
U.pop();L.pop();
return L.concat(U);
}
export default findConvexHull;
// Generation time: 1.623s
// Result: PASS

View File

@@ -0,0 +1,18 @@
const findLISLength = async arr => {
if (!Array.isArray(arr)) throw new TypeError('Input must be an array');
const { bisectLeft } = await import(
'https://cdn.jsdelivr.net/npm/d3-array@3.2.4/+esm'
);
const tails = [];
for (const v of arr) {
const i = bisectLeft(tails, v);
if (i === tails.length) tails.push(v);
else tails[i] = v;
}
return tails.length;
};
export default findLISLength;
// Generation time: 0.883s
// Result: PASS

View File

@@ -0,0 +1,8 @@
let hb
async function renderTemplate(t, d) {
hb = hb || (await import('https://cdn.jsdelivr.net/npm/handlebars@4.7.7/dist/handlebars.esm.js')).default
return hb.compile(t)(d)
}
export default renderTemplate;
// Generation time: 1.117s
// Result: FAIL

View File

@@ -0,0 +1,8 @@
async function parseMarkdown(s){
const MarkdownIt = (await import('https://cdn.jsdelivr.net/npm/markdown-it@13.0.1/dist/markdown-it.esm.js')).default;
const md = new MarkdownIt({html:false,linkify:true,typographer:true});
return md.render(s);
}
export default parseMarkdown;
// Generation time: 1.373s
// Result: FAIL

View File

@@ -0,0 +1,24 @@
async function processCSV(csv, cfg) {
const [{csvParse}] = await Promise.all([
import('https://cdn.skypack.dev/d3-dsv')
]);
const _ = await import('https://cdn.skypack.dev/lodash');
const rows = csvParse(csv);
const filtered = rows.filter(r => r[cfg.filterColumn] == cfg.filterValue);
const groups = _.groupBy(filtered, cfg.groupBy);
return Object.entries(groups).map(([k, g]) => {
let res;
if (cfg.operation === 'count') {
res = g.length;
} else {
const sum = g.reduce((s, r) => s + (Number(r[cfg.aggregateColumn]) || 0), 0);
res = cfg.operation === 'sum' ? sum : sum / g.length;
}
return { [cfg.groupBy]: k, result: res };
});
}
export default processCSV;
// Generation time: 1.891s
// Result: PASS

View File

@@ -0,0 +1,40 @@
async function findAvailableSlots(c1, c2, { durationMinutes: d, searchRange: { start: rs, end: re }, workHours: { start: whs, end: whe } }) {
const dayjs = (await import('https://cdn.skypack.dev/dayjs')).default;
const utc = (await import('https://cdn.skypack.dev/dayjs/plugin/utc')).default;
dayjs.extend(utc);
const to = s => dayjs.utc(s);
const busy = [...c1, ...c2].map(o => ({ s: to(o.start), e: to(o.end) })).sort((a, b) => a.s - b.s);
const merged = [];
for (const b of busy) {
if (!merged.length || b.s.isAfter(merged[merged.length - 1].e)) merged.push(b);
else if (b.e.isAfter(merged[merged.length - 1].e)) merged[merged.length - 1].e = b.e;
}
const sr = to(rs), er = to(re);
const free = [];
let cur = sr;
for (const b of merged) {
if (b.e.isAfter(cur)) {
if (b.s.isAfter(cur)) free.push({ s: cur, e: b.s });
cur = dayjs.max(cur, b.e);
}
}
if (cur.isBefore(er)) free.push({ s: cur, e: er });
const [whsh, whsm] = whs.split(':').map(Number);
const [wheh, whom] = whe.split(':').map(Number);
const slots = [];
for (let day = sr.startOf('day'); day.isBefore(er); day = day.add(1, 'day')) {
const ws = day.set('hour', whsh).set('minute', whsm);
const we = day.set('hour', wheh).set('minute', whom);
for (const f of free) {
const s = dayjs.max(f.s, ws);
const e = dayjs.min(f.e, we);
for (let t = s; !t.add(d, 'minute').isAfter(e); t = t.add(d, 'minute')) {
slots.push({ start: t.toISOString(), end: t.add(d, 'minute').toISOString() });
}
}
}
return slots;
}
export default findAvailableSlots;
// Generation time: 3.739s
// Result: FAIL

View File

@@ -0,0 +1,11 @@
async function validateJSON(d, s) {
const {default: Ajv} = await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.esm.js');
const {default: addFormats} = await import('https://cdn.jsdelivr.net/npm/ajv-formats@2/dist/ajv-formats.esm.js');
const v = new Ajv({allErrors: true, strict: false});
addFormats(v);
const ok = v.compile(s)(d);
return {valid: ok, errors: ok ? [] : v.errors.map(e => e.message)};
}
export default validateJSON;
// Generation time: 1.295s
// Result: FAIL

View File

@@ -0,0 +1,17 @@
async function createStreamVisualizer(src,{maxPoints=500,alpha=.5,width=800,height=600,yDomain}){
const d3=await import('https://cdn.jsdelivr.net/npm/d3@7')
const d=[];let e
for await(const{timestamp:t,value:v}of src){
e=e===undefined?v:alpha*v+(1-alpha)*e
d.push({timestamp:t,value:v,ema:e})
if(d.length>maxPoints)d.shift()
}
if(!d.length)return{data:[],path:''}
const x=d3.scaleLinear().domain([d[0].timestamp,d.at(-1).timestamp]).range([0,width])
const y=d3.scaleLinear().domain(yDomain||[d3.min(d,d=>d.ema),d3.max(d,d=>d.ema)]).range([height,0])
const p=d3.line().x(v=>x(v.timestamp)).y(v=>y(v.ema)).curve(d3.curveLinear)
return{data:d,path:p(d)}
}
export default createStreamVisualizer;
// Generation time: 1.456s
// Result: FAIL