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
This commit is contained in:
11
tests/10_scrypt_hash/outputs/anthropic_claude-opus-4.6.js
Normal file
11
tests/10_scrypt_hash/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -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.140s
|
||||||
|
// Result: PASS
|
||||||
17
tests/11_geospatial/outputs/anthropic_claude-opus-4.6.js
Normal file
17
tests/11_geospatial/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -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.691s
|
||||||
|
// Result: PASS
|
||||||
37
tests/1_dijkstra/outputs/anthropic_claude-opus-4.6.js
Normal file
37
tests/1_dijkstra/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
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 (node === end) return d;
|
||||||
|
if (visited.has(node)) continue;
|
||||||
|
visited.add(node);
|
||||||
|
|
||||||
|
if (!graph[node]) continue;
|
||||||
|
|
||||||
|
for (const [neighbor, weight] of Object.entries(graph[node])) {
|
||||||
|
const nd = d + weight;
|
||||||
|
if (nd < dist[neighbor]) {
|
||||||
|
dist[neighbor] = nd;
|
||||||
|
pq.queue([neighbor, nd]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dist[end] ?? Infinity;
|
||||||
|
}
|
||||||
|
export default findShortestPath;
|
||||||
|
// Generation time: 5.097s
|
||||||
|
// Result: FAIL
|
||||||
35
tests/2_convex_hull/outputs/anthropic_claude-opus-4.6.js
Normal file
35
tests/2_convex_hull/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -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.389s
|
||||||
|
// Result: PASS
|
||||||
12
tests/3_lis/outputs/anthropic_claude-opus-4.6.js
Normal file
12
tests/3_lis/outputs/anthropic_claude-opus-4.6.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.push(n) : tails[i] = n;
|
||||||
|
}
|
||||||
|
return tails.length;
|
||||||
|
}
|
||||||
|
export default findLISLength;
|
||||||
|
// Generation time: 3.057s
|
||||||
|
// Result: PASS
|
||||||
7
tests/4_transpiler/outputs/anthropic_claude-opus-4.6.js
Normal file
7
tests/4_transpiler/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
async function renderTemplate(template, data) {
|
||||||
|
const { default: Handlebars } = await import("https://esm.sh/handlebars");
|
||||||
|
return Handlebars.compile(template)(data);
|
||||||
|
}
|
||||||
|
export default renderTemplate;
|
||||||
|
// Generation time: 2.186s
|
||||||
|
// 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.453s
|
||||||
|
// Result: PASS
|
||||||
38
tests/6_csv_processor/outputs/anthropic_claude-opus-4.6.js
Normal file
38
tests/6_csv_processor/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
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 filtered = parsed.data.filter(row => row[filterColumn] == filterValue);
|
||||||
|
|
||||||
|
const groups = new Map();
|
||||||
|
for (const row of filtered) {
|
||||||
|
const key = row[groupBy];
|
||||||
|
if (!groups.has(key)) groups.set(key, []);
|
||||||
|
groups.get(key).push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
const toNum = v => {
|
||||||
|
const n = Number(v);
|
||||||
|
return Number.isFinite(n) ? n : 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
return [...groups.entries()].map(([groupValue, rows]) => {
|
||||||
|
let result;
|
||||||
|
if (operation === "count") {
|
||||||
|
result = rows.length;
|
||||||
|
} else {
|
||||||
|
const sum = rows.reduce((acc, r) => acc + toNum(r[aggregateColumn]), 0);
|
||||||
|
result = operation === "avg" ? sum / rows.length : sum;
|
||||||
|
}
|
||||||
|
return { [groupBy]: groupValue, result };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export default processCSV;
|
||||||
|
// Generation time: 5.843s
|
||||||
|
// Result: PASS
|
||||||
89
tests/7_scheduler/outputs/anthropic_claude-opus-4.6.js
Normal file
89
tests/7_scheduler/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
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 = { minutes: 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 =>
|
||||||
|
Interval.fromDateTimes(
|
||||||
|
DateTime.fromISO(b.start, { zone: "utc" }),
|
||||||
|
DateTime.fromISO(b.end, { zone: "utc" })
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const merged = Interval.merge(allBusy.filter(i => i.isValid));
|
||||||
|
|
||||||
|
const searchInterval = Interval.fromDateTimes(rangeStart, rangeEnd);
|
||||||
|
|
||||||
|
let freeIntervals = [searchInterval];
|
||||||
|
for (const busy of merged) {
|
||||||
|
const next = [];
|
||||||
|
for (const free of freeIntervals) {
|
||||||
|
const diff = free.difference(busy);
|
||||||
|
next.push(...diff);
|
||||||
|
}
|
||||||
|
freeIntervals = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
for (const free of freeIntervals) {
|
||||||
|
let cursor = free.start;
|
||||||
|
const freeEnd = free.end;
|
||||||
|
|
||||||
|
while (cursor < freeEnd) {
|
||||||
|
const dayStart = cursor.startOf("day").set({ hour: whStartH, minute: whStartM });
|
||||||
|
const dayEnd = cursor.startOf("day").set({ hour: whEndH, minute: whEndM });
|
||||||
|
|
||||||
|
if (cursor < dayStart) {
|
||||||
|
cursor = dayStart;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor >= dayEnd) {
|
||||||
|
cursor = cursor.startOf("day").plus({ days: 1 }).set({ hour: whStartH, minute: whStartM });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const slotEnd = cursor.plus(dur);
|
||||||
|
|
||||||
|
if (slotEnd > dayEnd) {
|
||||||
|
cursor = cursor.startOf("day").plus({ days: 1 }).set({ hour: whStartH, minute: whStartM });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slotEnd > freeEnd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slotEnd > rangeEnd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor < rangeStart) {
|
||||||
|
cursor = rangeStart;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
start: cursor.toISO(),
|
||||||
|
end: slotEnd.toISO()
|
||||||
|
});
|
||||||
|
|
||||||
|
cursor = slotEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
results.sort((a, b) => a.start < b.start ? -1 : a.start > b.start ? 1 : 0);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
export default findAvailableSlots;
|
||||||
|
// Generation time: 11.283s
|
||||||
|
// Result: PASS
|
||||||
12
tests/8_json_validator/outputs/anthropic_claude-opus-4.6.js
Normal file
12
tests/8_json_validator/outputs/anthropic_claude-opus-4.6.js
Normal file
@@ -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.023s
|
||||||
|
// 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.936s
|
||||||
|
// Result: PASS
|
||||||
Reference in New Issue
Block a user