mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for anthropic/claude-opus-4.6 TEMP:0.4
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
async function hashPassword(password, salt) {
|
||||
const { scrypt } = await import("https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm");
|
||||
const enc = new TextEncoder();
|
||||
const passwordBytes = enc.encode(password);
|
||||
const saltBytes = enc.encode(salt);
|
||||
const hash = await scrypt(passwordBytes, saltBytes, 1024, 8, 1, 32);
|
||||
return Array.from(hash, b => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
export default hashPassword;
|
||||
// Generation time: 3.538s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,17 @@
|
||||
async function analyzeGPS(readings, boundary) {
|
||||
const turf = await import("https://cdn.jsdelivr.net/npm/@turf/turf@7/+esm");
|
||||
|
||||
const valid = readings
|
||||
.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts);
|
||||
|
||||
if (valid.length < 2) return 0;
|
||||
|
||||
const line = turf.lineString(valid.map(r => r.loc));
|
||||
const len = turf.length(line, { units: "kilometers" });
|
||||
|
||||
return Math.round(len * 100) / 100;
|
||||
}
|
||||
export default analyzeGPS;
|
||||
// Generation time: 3.692s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,38 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PriorityQueue } = await import(
|
||||
"https://cdn.jsdelivr.net/npm/js-priority-queue@0.4.1/+esm"
|
||||
);
|
||||
|
||||
const dist = {};
|
||||
for (const node in graph) dist[node] = Infinity;
|
||||
dist[start] = 0;
|
||||
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
pq.queue([start, 0]);
|
||||
|
||||
const visited = new Set();
|
||||
|
||||
while (pq.length > 0) {
|
||||
const [node, d] = pq.dequeue();
|
||||
|
||||
if (visited.has(node)) continue;
|
||||
visited.add(node);
|
||||
|
||||
if (node === end) return d;
|
||||
|
||||
const neighbors = graph[node] || {};
|
||||
for (const neighbor in neighbors) {
|
||||
if (visited.has(neighbor)) continue;
|
||||
const newDist = d + neighbors[neighbor];
|
||||
if (newDist < dist[neighbor]) {
|
||||
dist[neighbor] = newDist;
|
||||
pq.queue([neighbor, newDist]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dist[end] ?? Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 5.576s
|
||||
// Result: FAIL
|
||||
@@ -0,0 +1,35 @@
|
||||
async function findConvexHull(points) {
|
||||
const _ = (await import("https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js")).default
|
||||
|| await import("https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js");
|
||||
|
||||
const unique = _.uniqWith(points, _.isEqual);
|
||||
const sorted = _.sortBy(unique, ["x", "y"]);
|
||||
|
||||
if (sorted.length <= 1) return sorted;
|
||||
|
||||
const cross = (O, A, B) =>
|
||||
(A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
|
||||
|
||||
const lower = [];
|
||||
for (const p of sorted) {
|
||||
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0)
|
||||
lower.pop();
|
||||
lower.push(p);
|
||||
}
|
||||
|
||||
const upper = [];
|
||||
for (let i = sorted.length - 1; i >= 0; i--) {
|
||||
const p = sorted[i];
|
||||
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0)
|
||||
upper.pop();
|
||||
upper.push(p);
|
||||
}
|
||||
|
||||
lower.pop();
|
||||
upper.pop();
|
||||
|
||||
return lower.concat(upper);
|
||||
}
|
||||
export default findConvexHull;
|
||||
// Generation time: 5.615s
|
||||
// Result: PASS
|
||||
12
tests/3_lis/outputs/anthropic_claude-opus-4.6 TEMP_0.4.js
Normal file
12
tests/3_lis/outputs/anthropic_claude-opus-4.6 TEMP_0.4.js
Normal file
@@ -0,0 +1,12 @@
|
||||
async function findLISLength(nums) {
|
||||
const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array/+esm");
|
||||
const tails = [];
|
||||
for (const n of nums) {
|
||||
const i = bisectLeft(tails, n);
|
||||
i < tails.length ? tails[i] = n : tails.push(n);
|
||||
}
|
||||
return tails.length;
|
||||
}
|
||||
export default findLISLength;
|
||||
// Generation time: 3.321s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,7 @@
|
||||
async function renderTemplate(template, data) {
|
||||
const { default: Handlebars } = await import("https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm");
|
||||
return Handlebars.compile(template)(data);
|
||||
}
|
||||
export default renderTemplate;
|
||||
// Generation time: 1.747s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,7 @@
|
||||
async function parseMarkdown(md) {
|
||||
const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js");
|
||||
return marked.parse(md);
|
||||
}
|
||||
export default parseMarkdown;
|
||||
// Generation time: 2.382s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,35 @@
|
||||
async function processCSV(csv, config) {
|
||||
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
|
||||
|
||||
const { default: Papa } = await import("https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm");
|
||||
|
||||
const parsed = Papa.parse(csv.trim(), { header: true, skipEmptyLines: true });
|
||||
const rows = parsed.data;
|
||||
|
||||
const filtered = rows.filter(r => r[filterColumn] == filterValue);
|
||||
|
||||
const groups = {};
|
||||
for (const row of filtered) {
|
||||
const key = row[groupBy];
|
||||
if (!groups[key]) groups[key] = [];
|
||||
groups[key].push(row);
|
||||
}
|
||||
|
||||
return Object.entries(groups).map(([groupValue, groupRows]) => {
|
||||
let result;
|
||||
if (operation === "count") {
|
||||
result = groupRows.length;
|
||||
} else {
|
||||
const vals = groupRows.map(r => {
|
||||
const n = Number(r[aggregateColumn]);
|
||||
return isNaN(n) ? 0 : n;
|
||||
});
|
||||
const sum = vals.reduce((a, b) => a + b, 0);
|
||||
result = operation === "avg" ? sum / groupRows.length : sum;
|
||||
}
|
||||
return { [groupBy]: groupValue, result };
|
||||
});
|
||||
}
|
||||
export default processCSV;
|
||||
// Generation time: 4.670s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,87 @@
|
||||
async function findAvailableSlots(calendar1, calendar2, constraints) {
|
||||
const { DateTime, Interval } = await import("https://cdn.jsdelivr.net/npm/luxon@3/+esm");
|
||||
|
||||
const { durationMinutes, searchRange, workHours } = constraints;
|
||||
const dur = durationMinutes;
|
||||
|
||||
const rangeStart = DateTime.fromISO(searchRange.start, { zone: "utc" });
|
||||
const rangeEnd = DateTime.fromISO(searchRange.end, { zone: "utc" });
|
||||
|
||||
const [whStartH, whStartM] = workHours.start.split(":").map(Number);
|
||||
const [whEndH, whEndM] = workHours.end.split(":").map(Number);
|
||||
|
||||
const allBusy = [...calendar1, ...calendar2]
|
||||
.map(b => ({
|
||||
s: DateTime.fromISO(b.start, { zone: "utc" }),
|
||||
e: DateTime.fromISO(b.end, { zone: "utc" })
|
||||
}))
|
||||
.sort((a, b) => a.s - b.s);
|
||||
|
||||
const merged = [];
|
||||
for (const slot of allBusy) {
|
||||
if (merged.length && slot.s <= merged[merged.length - 1].e) {
|
||||
merged[merged.length - 1].e = DateTime.max(merged[merged.length - 1].e, slot.e);
|
||||
} else {
|
||||
merged.push({ s: slot.s, e: slot.e });
|
||||
}
|
||||
}
|
||||
|
||||
const freePeriods = [];
|
||||
let cursor = rangeStart;
|
||||
|
||||
for (const busy of merged) {
|
||||
if (busy.s > cursor) {
|
||||
freePeriods.push({ s: cursor, e: DateTime.min(busy.s, rangeEnd) });
|
||||
}
|
||||
cursor = DateTime.max(cursor, busy.e);
|
||||
if (cursor >= rangeEnd) break;
|
||||
}
|
||||
|
||||
if (cursor < rangeEnd) {
|
||||
freePeriods.push({ s: cursor, e: rangeEnd });
|
||||
}
|
||||
|
||||
const workConstrained = [];
|
||||
|
||||
for (const free of freePeriods) {
|
||||
let day = free.s.startOf("day");
|
||||
const lastDay = free.e.startOf("day");
|
||||
|
||||
while (day <= lastDay) {
|
||||
const whS = day.set({ hour: whStartH, minute: whStartM, second: 0, millisecond: 0 });
|
||||
const whE = day.set({ hour: whEndH, minute: whEndM, second: 0, millisecond: 0 });
|
||||
|
||||
const overlapStart = DateTime.max(free.s, whS, rangeStart);
|
||||
const overlapEnd = DateTime.min(free.e, whE, rangeEnd);
|
||||
|
||||
if (overlapStart < overlapEnd) {
|
||||
workConstrained.push({ s: overlapStart, e: overlapEnd });
|
||||
}
|
||||
|
||||
day = day.plus({ days: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
const results = [];
|
||||
|
||||
for (const period of workConstrained) {
|
||||
let slotStart = period.s;
|
||||
|
||||
while (true) {
|
||||
const slotEnd = slotStart.plus({ minutes: dur });
|
||||
if (slotEnd > period.e) break;
|
||||
results.push({
|
||||
start: slotStart.toISO(),
|
||||
end: slotEnd.toISO()
|
||||
});
|
||||
slotStart = slotEnd;
|
||||
}
|
||||
}
|
||||
|
||||
results.sort((a, b) => a.start.localeCompare(b.start));
|
||||
|
||||
return results;
|
||||
}
|
||||
export default findAvailableSlots;
|
||||
// Generation time: 11.229s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,12 @@
|
||||
async function validateJSON(json, schema) {
|
||||
const { default: Ajv } = await import("https://esm.sh/ajv@8");
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
const valid = ajv.validate(schema, json);
|
||||
return {
|
||||
valid,
|
||||
errors: valid ? [] : ajv.errors.map(e => `${e.instancePath || "/"} ${e.message}`)
|
||||
};
|
||||
}
|
||||
export default validateJSON;
|
||||
// Generation time: 3.592s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,36 @@
|
||||
async function createStreamVisualizer(asyncIterable, options) {
|
||||
const { maxPoints, alpha, width, height, yDomain } = options;
|
||||
|
||||
const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
|
||||
|
||||
const data = [];
|
||||
let prevEma = null;
|
||||
|
||||
for await (const { timestamp, value } of asyncIterable) {
|
||||
const ema = prevEma === null
|
||||
? value
|
||||
: alpha * value + (1 - alpha) * prevEma;
|
||||
prevEma = ema;
|
||||
data.push({ timestamp, value, ema });
|
||||
if (data.length > maxPoints) data.shift();
|
||||
}
|
||||
|
||||
const xScale = d3.scaleLinear()
|
||||
.domain([data[0].timestamp, data[data.length - 1].timestamp])
|
||||
.range([0, width]);
|
||||
|
||||
const yScale = d3.scaleLinear()
|
||||
.domain(yDomain)
|
||||
.range([height, 0]);
|
||||
|
||||
const lineGen = d3.line()
|
||||
.x(d => xScale(d.timestamp))
|
||||
.y(d => yScale(d.ema));
|
||||
|
||||
const path = lineGen(data);
|
||||
|
||||
return { data, path };
|
||||
}
|
||||
export default createStreamVisualizer;
|
||||
// Generation time: 4.923s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user