mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 16:47:55 +00:00
Docs: Update benchmark for openrouter/sherlock-think-alpha
This commit is contained in:
11
results.json
11
results.json
@@ -53,5 +53,16 @@
|
|||||||
"7_scheduler": 184.65146969499997,
|
"7_scheduler": 184.65146969499997,
|
||||||
"8_json_validator": 81.96185510699998,
|
"8_json_validator": 81.96185510699998,
|
||||||
"9_stream_visualizer": 31.27018206100003
|
"9_stream_visualizer": 31.27018206100003
|
||||||
|
},
|
||||||
|
"openrouter/sherlock-think-alpha": {
|
||||||
|
"1_dijkstra": 34.012272204,
|
||||||
|
"2_convex_hull": 47.377176928,
|
||||||
|
"3_lis": 18.49963934400001,
|
||||||
|
"4_determinant": 20.327296623999995,
|
||||||
|
"5_markdown_parser": 34.069916891999995,
|
||||||
|
"6_csv_processor": 19.902450771000005,
|
||||||
|
"7_scheduler": 82.133111714,
|
||||||
|
"8_json_validator": 31.42142794699996,
|
||||||
|
"9_stream_visualizer": 35.74114956699999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
22
tests/1_dijkstra/outputs/openrouter_sherlock-think-alpha.js
Normal file
22
tests/1_dijkstra/outputs/openrouter_sherlock-think-alpha.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
async function findShortestPath(graph,start,end){
|
||||||
|
const{PriorityQueue}=await import('https://cdn.skypack.dev/js-priority-queue');
|
||||||
|
const dist={};
|
||||||
|
for(let n in graph)dist[n]=Infinity;
|
||||||
|
dist[start]=0;
|
||||||
|
const pq=new PriorityQueue({comparator:(a,b)=>a.d-b.d});
|
||||||
|
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(let nei in graph[node]){
|
||||||
|
const alt=d+graph[node][nei];
|
||||||
|
if(alt<dist[nei]){
|
||||||
|
dist[nei]=alt;
|
||||||
|
pq.queue({node:nei,d:alt});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Infinity;
|
||||||
|
}
|
||||||
|
export default findShortestPath;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
async function findConvexHull(pts){
|
||||||
|
const _=(await import('https://esm.run/lodash@4.17.21')).default;
|
||||||
|
let p=_.uniqBy(_.sortBy(pts,['x','y']),q=>[q.x,q.y]);
|
||||||
|
if(p.length<=2)return p;
|
||||||
|
const cross=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
|
||||||
|
let lower=[];
|
||||||
|
for(let q of p){
|
||||||
|
while(lower.length>=2&&cross(lower[lower.length-2],lower[lower.length-1],q)<=0)lower.pop();
|
||||||
|
lower.push(q);
|
||||||
|
}
|
||||||
|
let upper=[];
|
||||||
|
let rp=[...p].reverse();
|
||||||
|
for(let q of rp){
|
||||||
|
while(upper.length>=2&&cross(upper[upper.length-2],upper[upper.length-1],q)<=0)upper.pop();
|
||||||
|
upper.push(q);
|
||||||
|
}
|
||||||
|
return lower.slice(0,-1).concat(upper.slice(0,-1));
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
14
tests/3_lis/outputs/openrouter_sherlock-think-alpha.js
Normal file
14
tests/3_lis/outputs/openrouter_sherlock-think-alpha.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
async function findLISLength(arr) {
|
||||||
|
const {bisectLeft} = await import('https://cdn.skypack.dev/d3-array');
|
||||||
|
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;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
async function calculateDeterminant(matrix) {
|
||||||
|
const { det } = await import('https://esm.sh/mathjs');
|
||||||
|
return det(matrix);
|
||||||
|
}
|
||||||
|
export default calculateDeterminant;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
async function parseMarkdown(text) {
|
||||||
|
const {marked} = await import('https://unpkg.com/marked@14.1.2?module');
|
||||||
|
return marked(text);
|
||||||
|
}
|
||||||
|
export default parseMarkdown;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
async function processCSV(csvString,config){
|
||||||
|
const{default:Papa}=await import('https://esm.sh/papaparse');
|
||||||
|
const{filterColumn:fc,filterValue:fv,groupBy:gb,aggregateColumn:ac,operation:op}=config;
|
||||||
|
const parsed=Papa.parse(csvString,{header:true}).data;
|
||||||
|
const filtered=parsed.filter(r=>r[fc]==fv);
|
||||||
|
const groups=filtered.reduce((acc,r)=>{
|
||||||
|
const k=r[gb];
|
||||||
|
const v=Number(r[ac])||0;
|
||||||
|
if(!acc[k])acc[k]={s:0,c:0};
|
||||||
|
acc[k].s+=v;
|
||||||
|
acc[k].c++;
|
||||||
|
return acc;
|
||||||
|
},{});
|
||||||
|
return Object.entries(groups).map(([k,g])=>{
|
||||||
|
const res=op==='count'?g.c:op==='sum'?g.s:g.s/g.c;
|
||||||
|
return{[gb]:k,result:res};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export default processCSV;
|
||||||
77
tests/7_scheduler/outputs/openrouter_sherlock-think-alpha.js
Normal file
77
tests/7_scheduler/outputs/openrouter_sherlock-think-alpha.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
async function findAvailableSlots(cal1, cal2, constraints) {
|
||||||
|
const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon');
|
||||||
|
const { durationMinutes, searchRange, workHours } = constraints;
|
||||||
|
const searchStart = DateTime.fromISO(searchRange.start);
|
||||||
|
const searchEnd = DateTime.fromISO(searchRange.end);
|
||||||
|
const searchInterval = Interval.fromDateTimes(searchStart, searchEnd);
|
||||||
|
const zone = searchStart.zone;
|
||||||
|
const workStart = DateTime.fromFormat(workHours.start, 'HH:mm', { zone });
|
||||||
|
const workEnd = DateTime.fromFormat(workHours.end, 'HH:mm', { zone });
|
||||||
|
let busies = [];
|
||||||
|
for (const slot of [...cal1, ...cal2]) {
|
||||||
|
const iv = Interval.fromISO(`${slot.start}/${slot.end}`);
|
||||||
|
const i = iv.intersection(searchInterval);
|
||||||
|
if (i?.isValid) busies.push(i);
|
||||||
|
}
|
||||||
|
let nonWork = [];
|
||||||
|
let currentDay = searchStart.startOf('day');
|
||||||
|
const endDay = searchEnd.endOf('day');
|
||||||
|
while (currentDay <= endDay) {
|
||||||
|
const dayStart = currentDay;
|
||||||
|
const dayEnd = currentDay.plus({ days: 1 });
|
||||||
|
const wStart = dayStart.set({ hour: workStart.hour, minute: workStart.minute, second: 0, millisecond: 0 });
|
||||||
|
const wEnd = dayStart.set({ hour: workEnd.hour, minute: workEnd.minute, second: 0, millisecond: 0 });
|
||||||
|
const blocks = [];
|
||||||
|
if (dayStart < wStart) blocks.push(Interval.fromDateTimes(dayStart, wStart));
|
||||||
|
if (wEnd < dayEnd) blocks.push(Interval.fromDateTimes(wEnd, dayEnd));
|
||||||
|
for (const b of blocks) {
|
||||||
|
const i = b.intersection(searchInterval);
|
||||||
|
if (i?.isValid) nonWork.push(i);
|
||||||
|
}
|
||||||
|
currentDay = currentDay.plus({ days: 1 });
|
||||||
|
}
|
||||||
|
let allBlocked = [...busies, ...nonWork].sort((a, b) => a.start.valueOf() - b.start.valueOf());
|
||||||
|
const mergedBlocked = [];
|
||||||
|
for (const iv of allBlocked) {
|
||||||
|
const last = mergedBlocked.at(-1);
|
||||||
|
if (!last || !last.overlaps(iv)) {
|
||||||
|
mergedBlocked.push(iv);
|
||||||
|
} else {
|
||||||
|
mergedBlocked[mergedBlocked.length - 1] = last.union(iv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const freePeriods = [];
|
||||||
|
if (mergedBlocked.length === 0) {
|
||||||
|
freePeriods.push(searchInterval);
|
||||||
|
} else {
|
||||||
|
if (searchStart < mergedBlocked[0].start) {
|
||||||
|
freePeriods.push(Interval.fromDateTimes(searchStart, mergedBlocked[0].start));
|
||||||
|
}
|
||||||
|
for (let i = 0; i < mergedBlocked.length - 1; i++) {
|
||||||
|
const gapStart = mergedBlocked[i].end;
|
||||||
|
const gapEnd = mergedBlocked[i + 1].start;
|
||||||
|
if (gapStart < gapEnd) {
|
||||||
|
freePeriods.push(Interval.fromDateTimes(gapStart, gapEnd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mergedBlocked.at(-1).end < searchEnd) {
|
||||||
|
freePeriods.push(Interval.fromDateTimes(mergedBlocked.at(-1).end, searchEnd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const availableSlots = [];
|
||||||
|
for (const freeIv of freePeriods) {
|
||||||
|
if (freeIv.length('milliseconds') < durationMinutes * 60 * 1000) continue;
|
||||||
|
let current = freeIv.start;
|
||||||
|
while (true) {
|
||||||
|
const slotEnd = current.plus({ minutes: durationMinutes });
|
||||||
|
if (slotEnd > freeIv.end) break;
|
||||||
|
availableSlots.push({
|
||||||
|
start: current.toISO(),
|
||||||
|
end: slotEnd.toISO()
|
||||||
|
});
|
||||||
|
current = slotEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return availableSlots;
|
||||||
|
}
|
||||||
|
export default findAvailableSlots;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
const getAjv = async () => {
|
||||||
|
if (!getAjv.instance) {
|
||||||
|
const { default: Ajv } = await import('https://cdn.skypack.dev/ajv@8');
|
||||||
|
getAjv.instance = new Ajv({ allErrors: true });
|
||||||
|
}
|
||||||
|
return getAjv.instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateJSON = async (data, schema) => {
|
||||||
|
try {
|
||||||
|
const ajv = await getAjv();
|
||||||
|
const validate = ajv.compile(schema);
|
||||||
|
const valid = validate(data);
|
||||||
|
const errors = valid ? [] : ajv.errorsText(ajv.errors, { separator: '\n' }).split('\n').filter(s => s.trim());
|
||||||
|
return { valid, errors };
|
||||||
|
} catch (e) {
|
||||||
|
return { valid: false, errors: [`Validation error: ${e.message}`] };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default validateJSON;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
async function createStreamVisualizer(iter,opts){
|
||||||
|
const{maxPoints:max,alpha,width,height,yDomain}=opts;
|
||||||
|
let data=[],prev=null;
|
||||||
|
for await(const i of iter){
|
||||||
|
const ts=i.timestamp,v=i.value,e=prev==null?v:alpha*v+(1-alpha)*prev;
|
||||||
|
prev=e;
|
||||||
|
data.push({timestamp:ts,value:v,ema:e});
|
||||||
|
if(data.length>max)data.shift();
|
||||||
|
}
|
||||||
|
const{scaleLinear,line}=await import('https://cdn.skypack.dev/d3');
|
||||||
|
if(!data.length)return{data,path:''};
|
||||||
|
const x=scaleLinear().domain([data[0].timestamp,data.at(-1).timestamp]).range([0,width]);
|
||||||
|
const y=scaleLinear().domain(yDomain).range([height,0]);
|
||||||
|
return{data,line().x(d=>x(d.timestamp)).y(d=>y(d.ema))(data)};
|
||||||
|
}
|
||||||
|
export default createStreamVisualizer;
|
||||||
Reference in New Issue
Block a user