Docs: Update benchmark for x-ai/grok-4.1-fast

This commit is contained in:
github-actions[bot]
2025-11-20 01:45:32 +00:00
parent ba05809576
commit 932fcdce31
12 changed files with 199 additions and 0 deletions

View File

@@ -362,5 +362,18 @@
"7_scheduler": 79.87219575399999,
"8_json_validator": 28.535885181999998,
"9_stream_visualizer": 21.60573508199997
},
"x-ai/grok-4.1-fast": {
"10_scrypt_hash": 7.757944809,
"11_geospatial": 53.446182177,
"1_dijkstra": 27.758440794000002,
"2_convex_hull": 36.94094523,
"3_lis": 21.781018421000002,
"4_determinant": 6.4344023279999965,
"5_markdown_parser": 14.127124740999978,
"6_csv_processor": 56.944877974,
"7_scheduler": 48.61515529499997,
"8_json_validator": 36.715725561,
"9_stream_visualizer": 20.464613763000003
}
}

View File

@@ -0,0 +1,9 @@
async function hashPassword(password, salt) {
const { scrypt } = await import('https://cdn.skypack.dev/scrypt-js');
const encoder = new TextEncoder();
const pwBuf = encoder.encode(password);
const saltBuf = encoder.encode(salt);
const hashBuf = await scrypt(pwBuf, saltBuf, 1024, 8, 1, 32);
return Array.from(hashBuf).map(b => b.toString(16).padStart(2, '0')).join('');
}
export default hashPassword;

View File

@@ -0,0 +1,6 @@
async function analyzeGPS(readings, boundary) {
const { point: p, booleanPointInPolygon: i, lineString: s, length: l } = await import('https://esm.sh/@turf/turf@6');
const v = readings.filter(r => i(p(r.loc), boundary)).sort((a, b) => a.ts - b.ts);
return v.length < 2 ? 0 : +l(s(v.map(r => r.loc))).toFixed(2);
}
export default analyzeGPS;

View File

@@ -0,0 +1,21 @@
async function findShortestPath(graph, start, end) {
const { PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
const pq = new PriorityQueue({ comparator: (a, b) => a.d - b.d });
const dist = {};
dist[start] = 0;
pq.queue({ node: start, d: 0 });
while (!pq.isEmpty()) {
const { node, d } = pq.dequeue();
if (d > dist[node]) continue;
if (node === end) return d;
for (const [nei, w] of Object.entries(graph[node] || {})) {
const alt = d + w;
if (alt < (dist[nei] ?? Infinity)) {
dist[nei] = alt;
pq.queue({ node: nei, d: alt });
}
}
}
return Infinity;
}
export default findShortestPath;

View File

@@ -0,0 +1,19 @@
async function findConvexHull(pts) {
const { sortBy, uniqBy } = await import('https://cdn.skypack.dev/lodash-es');
const ps = uniqBy(pts, p => `${p.x},${p.y}`);
if (ps.length < 2) return ps;
const sorted = sortBy(ps, ['x', 'y']);
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const build = (pnts) => {
const h = [];
for (let p of pnts) {
while (h.length > 1 && cross(h[h.length - 2], h.at(-1), p) <= 0) h.pop();
h.push(p);
}
return h;
};
const lower = build(sorted);
const upper = build([...sorted].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
}
export default findConvexHull;

View File

@@ -0,0 +1,11 @@
async function findLISLength(arr) {
const {bisectLeft} = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
let tails = [];
for (let num of arr) {
let i = bisectLeft(tails, num);
if (i === tails.length) tails.push(num);
else tails[i] = num;
}
return tails.length;
}
export default findLISLength;

View File

@@ -0,0 +1,5 @@
async function calculateDeterminant(matrix) {
const { default: math } = await import('https://cdn.jsdelivr.net/npm/mathjs/lib/browser/math.js');
return math.det(matrix);
}
export default calculateDeterminant;

View File

@@ -0,0 +1,5 @@
async function parseMarkdown(md) {
const { marked } = await import('https://cdn.skypack.dev/marked');
return marked.parse(md);
}
export default parseMarkdown;

View File

@@ -0,0 +1,15 @@
async function processCSV(csv, config) {
const [{ default: Papa }, { aq, sum, mean, count }] = await Promise.all([
import('https://cdn.skypack.dev/papaparse'),
import('https://cdn.skypack.dev/arquero')
]);
const data = Papa.parse(csv, { header: true, skipEmptyLines: true }).data;
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
let table = aq.from(data).filter(d => d[filterColumn] == filterValue);
if (operation !== 'count') {
table = table.derive({ [aggregateColumn]: d => Number(d[aggregateColumn]) || 0 });
}
const makeAgg = operation === 'count' ? count() : { sum: sum, avg: mean }[operation](aggregateColumn);
return table.groupby(groupBy).rollup({ result: makeAgg }).objects();
}
export default processCSV;

View File

@@ -0,0 +1,64 @@
async function findAvailableSlots(cal1, cal2, constraints) {
const { DateTime, Interval } = await import('https://esm.sh/luxon@3');
const busySlots = [...cal1, ...cal2].map(slot => {
const s = DateTime.fromISO(slot.start, { zone: 'utc' });
const e = DateTime.fromISO(slot.end, { zone: 'utc' });
return s.isValid && e.isValid && s < e ? Interval.fromDateTimes(s, e) : null;
}).filter(Boolean);
const mergedBusies = Interval.union(busySlots);
const rangeStart = DateTime.fromISO(constraints.searchRange.start, { zone: 'utc' });
const rangeEnd = DateTime.fromISO(constraints.searchRange.end, { zone: 'utc' });
const searchInt = Interval.fromDateTimes(rangeStart, rangeEnd);
let covered = mergedBusies
.filter(b => searchInt.overlaps(b))
.map(b => searchInt.intersection(b))
.filter(i => i.isValid);
covered.sort((a, b) => a.start.toMillis() - b.start.toMillis());
const frees = [];
let current = rangeStart;
for (const busy of covered) {
if (current < busy.start) {
frees.push(Interval.fromDateTimes(current, busy.start));
}
current = DateTime.max(current, busy.end);
}
if (current < rangeEnd) {
frees.push(Interval.fromDateTimes(current, rangeEnd));
}
const [wsH, wsM] = constraints.workHours.start.split(':').map(Number);
const [weH, weM] = constraints.workHours.end.split(':').map(Number);
const durMin = constraints.durationMinutes;
let workInts = [];
let curDay = rangeStart.startOf('day');
const endDayStart = rangeEnd.startOf('day');
while (curDay <= endDayStart) {
const dayWorkS = curDay.set({ hour: wsH, minute: wsM });
const dayWorkE = curDay.set({ hour: weH, minute: weM });
if (dayWorkS < dayWorkE) {
workInts.push(Interval.fromDateTimes(dayWorkS, dayWorkE));
}
curDay = curDay.plus({ days: 1 });
}
const allowables = [];
for (const free of frees) {
for (const work of workInts) {
const inter = free.intersection(work);
if (inter.isValid) allowables.push(inter);
}
}
const mergedAllows = Interval.union(allowables);
const availableSlots = [];
for (const allow of mergedAllows) {
let slotStart = allow.start;
while (allow.contains(slotStart.plus({ minutes: durMin }))) {
const slotEnd = slotStart.plus({ minutes: durMin });
availableSlots.push({
start: slotStart.toISO(),
end: slotEnd.toISO()
});
slotStart = slotEnd;
}
}
return availableSlots;
}
export default findAvailableSlots;

View File

@@ -0,0 +1,10 @@
async function validateJSON(data,schema){
const{default:Ajv}=await import('https://esm.sh/ajv@7.13.4');
const ajv=new Ajv({allErrors:true});
const validate=ajv.compile(schema);
const valid=validate(data);
if(valid)return{valid:true,errors:[]};
const errors=validate.errors.map(e=>`${e.instancePath||''} ${e.message||'Validation error'}`.trim()).filter(Boolean);
return{valid:false,errors};
}
export default validateJSON;

View File

@@ -0,0 +1,21 @@
async function createStreamVisualizer(iter,opts){
const d3=await import('https://cdn.skypack.dev/d3');
const {maxPoints=500,alpha=.1,width=800,height=400,yDomain:[0,1]}=opts;
let data=[],prevEma=null;
for await(const {timestamp:t,value:v}of iter){
const ema=prevEma===null?v:alpha*v+(1-alpha)*prevEma;
prevEma=ema;
data.push({timestamp:t,value:v,ema});
if(data.length>maxPoints)data.shift();
}
if(data.length<2)return{data,path:"M 0 0"};
const x0=data[0].timestamp,x1=data.at(-1).timestamp;
const xScale=d3.scaleLinear().domain([x0,x1]).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))
.curve(d3.curveMonotoneX);
return{data,path:line(data)};
}
export default createStreamVisualizer;