From 79886a435d389507bd593da4d87a3c4feb08c1a3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Feb 2026 22:10:27 +0000 Subject: [PATCH] Docs: Update benchmark for anthropic/claude-sonnet-4.6 --- .../outputs/anthropic_claude-sonnet-4.6.js | 9 ++ .../outputs/anthropic_claude-sonnet-4.6.js | 15 +++ .../outputs/anthropic_claude-sonnet-4.6.js | 46 ++++++++ .../outputs/anthropic_claude-sonnet-4.6.js | 31 +++++ .../outputs/anthropic_claude-sonnet-4.6.js | 26 +++++ .../outputs/anthropic_claude-sonnet-4.6.js | 17 +++ .../outputs/anthropic_claude-sonnet-4.6.js | 9 ++ .../outputs/anthropic_claude-sonnet-4.6.js | 7 ++ .../outputs/anthropic_claude-sonnet-4.6.js | 30 +++++ .../outputs/anthropic_claude-sonnet-4.6.js | 106 ++++++++++++++++++ .../outputs/anthropic_claude-sonnet-4.6.js | 23 ++++ .../outputs/anthropic_claude-sonnet-4.6.js | 31 +++++ 12 files changed, 350 insertions(+) create mode 100644 tests/10_scrypt_hash/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/11_geospatial/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/12_mst_pipeline/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/3_lis/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/4_transpiler/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/7_scheduler/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/8_json_validator/outputs/anthropic_claude-sonnet-4.6.js create mode 100644 tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.6.js diff --git a/tests/10_scrypt_hash/outputs/anthropic_claude-sonnet-4.6.js b/tests/10_scrypt_hash/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..d3679c6 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,9 @@ +const hashPassword = async (password, salt) => { + const { scrypt } = (await import("https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.js/+esm")); + const enc = new TextEncoder(); + const hash = await scrypt(enc.encode(password), enc.encode(salt), 1024, 8, 1, 32); + return Array.from(hash).map(b => b.toString(16).padStart(2, "0")).join(""); +}; +export default hashPassword; +// Generation time: 2.204s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/anthropic_claude-sonnet-4.6.js b/tests/11_geospatial/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..4d18438 --- /dev/null +++ b/tests/11_geospatial/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,15 @@ +async function analyzeGPS(readings, boundary) { + const { default: turf } = await import("https://cdn.skypack.dev/@turf/turf"); + + const valid = readings + .filter(({ loc }) => turf.booleanPointInPolygon(turf.point(loc), boundary)) + .sort((a, b) => a.ts - b.ts); + + if (valid.length < 2) return 0; + + const line = turf.lineString(valid.map(({ loc }) => loc)); + return Math.round(turf.length(line, { units: "kilometers" }) * 100) / 100; +} +export default analyzeGPS; +// Generation time: 2.529s +// Result: FAIL \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/anthropic_claude-sonnet-4.6.js b/tests/12_mst_pipeline/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..1f663f0 --- /dev/null +++ b/tests/12_mst_pipeline/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,46 @@ +async function computeMST(tomlString) { + const [{ parse }, { default: Heap }, { default: textTable }] = await Promise.all([ + import("https://esm.sh/smol-toml"), + import("https://esm.sh/mnemonist/heap.js"), + import("https://esm.sh/text-table"), + ]); + + const { edges } = parse(tomlString); + + const heap = new Heap((a, b) => a.weight - b.weight); + edges.forEach(e => heap.push(e)); + + const nodes = [...new Set(edges.flatMap(e => [e.from, e.to]))]; + const parent = Object.fromEntries(nodes.map(n => [n, n])); + const rank = Object.fromEntries(nodes.map(n => [n, 0])); + + const find = n => { + if (parent[n] !== n) parent[n] = find(parent[n]); + return parent[n]; + }; + + const union = (a, b) => { + const [ra, rb] = [find(a), find(b)]; + if (ra === rb) return false; + if (rank[ra] < rank[rb]) parent[ra] = rb; + else if (rank[ra] > rank[rb]) parent[rb] = ra; + else { parent[rb] = ra; rank[ra]++; } + return true; + }; + + const mstEdges = []; + const limit = nodes.length - 1; + + while (heap.size && mstEdges.length < limit) { + const { from, to, weight } = heap.pop(); + if (union(from, to)) mstEdges.push([from, to, String(weight)]); + } + + const totalWeight = mstEdges.reduce((s, [,, w]) => s + Number(w), 0); + const table = textTable([["From", "To", "Weight"], ...mstEdges]); + + return { table, totalWeight }; +} +export default computeMST; +// Generation time: 5.943s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.6.js b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..76acc07 --- /dev/null +++ b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,31 @@ +const findShortestPath = async (graph, start, end) => { + const { default: PriorityQueue } = await import( + "https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.js" + ); + + const pq = new PriorityQueue({ comparator: (a, b) => a[0] - b[0] }); + const dist = Object.fromEntries(Object.keys(graph).map((n) => [n, Infinity])); + + dist[start] = 0; + pq.queue([0, start]); + + while (pq.length) { + const [d, u] = pq.dequeue(); + + if (d > dist[u]) continue; + if (u === end) return d; + + for (const [v, w] of Object.entries(graph[u] ?? {})) { + const nd = d + w; + if (nd < dist[v]) { + dist[v] = nd; + pq.queue([nd, v]); + } + } + } + + return dist[end]; +}; +export default findShortestPath; +// Generation time: 4.396s +// Result: FAIL \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.6.js b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..40d71ee --- /dev/null +++ b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,26 @@ +async function findConvexHull(points) { + const { default: _ } = await import("https://cdn.skypack.dev/lodash"); + + const unique = _.uniqWith(points, _.isEqual); + const sorted = _.sortBy(unique, ["x", "y"]); + + if (sorted.length < 3) return sorted; + + const cross = (o, a, b) => + (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + + const buildHalf = (pts) => + pts.reduce((hull, p) => { + while (hull.length >= 2 && cross(hull.at(-2), hull.at(-1), p) <= 0) + hull.pop(); + return [...hull, p]; + }, []); + + const lower = buildHalf(sorted); + const upper = buildHalf([...sorted].reverse()); + + return [...lower.slice(0, -1), ...upper.slice(0, -1)]; +} +export default findConvexHull; +// Generation time: 3.848s +// Result: PASS \ No newline at end of file diff --git a/tests/3_lis/outputs/anthropic_claude-sonnet-4.6.js b/tests/3_lis/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..05ed301 --- /dev/null +++ b/tests/3_lis/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,17 @@ +async function findLISLength(nums) { + if (!nums?.length) return 0; + + const { bisectLeft } = await import("https://cdn.skypack.dev/d3-array"); + + const tails = []; + + for (const n of nums) { + const i = bisectLeft(tails, n); + tails[i] = n; + } + + return tails.length; +} +export default findLISLength; +// Generation time: 1.943s +// Result: PASS \ No newline at end of file diff --git a/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.6.js b/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..1e20cf3 --- /dev/null +++ b/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,9 @@ +const renderTemplate = async (template, data) => { + const { default: Handlebars } = await import( + "https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.esm.min.js" + ); + return Handlebars.compile(template)(data); +}; +export default renderTemplate; +// Generation time: 1.675s +// Result: FAIL \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.6.js b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..c99bacb --- /dev/null +++ b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,7 @@ +const parseMarkdown = async (markdown) => { + const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/src/marked.esm.js"); + return marked.parse(markdown); +}; +export default parseMarkdown; +// Generation time: 1.296s +// Result: FAIL \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.6.js b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..410924f --- /dev/null +++ b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,30 @@ +async function processCSV(csvString, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) { + const [{ default: Papa }] = await Promise.all([ + import("https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm"), + ]); + + const { data } = Papa.parse(csvString.trim(), { header: true, skipEmptyLines: true }); + + const filtered = data.filter(row => row[filterColumn] == filterValue); + + const groups = filtered.reduce((acc, row) => { + const key = row[groupBy]; + (acc[key] ??= []).push(row); + return acc; + }, {}); + + const toNum = v => { const n = Number(v); return isNaN(n) ? 0 : n; }; + + return Object.entries(groups).map(([groupValue, rows]) => { + const vals = rows.map(r => toNum(r[aggregateColumn])); + const sum = vals.reduce((a, b) => a + b, 0); + const result = + operation === "sum" ? sum : + operation === "avg" ? sum / rows.length : + operation === "count" ? rows.length : 0; + return { [groupBy]: groupValue, result }; + }); +} +export default processCSV; +// Generation time: 4.438s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.6.js b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..fea0e1c --- /dev/null +++ b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,106 @@ +async function findAvailableSlots(calendar1, calendar2, constraints) { + const { default: dayjs } = await import("https://cdn.skypack.dev/dayjs@1.11.10"); + const { default: utc } = await import("https://cdn.skypack.dev/dayjs@1.11.10/plugin/utc"); + const { default: customParseFormat } = await import("https://cdn.skypack.dev/dayjs@1.11.10/plugin/customParseFormat"); + + dayjs.extend(utc); + dayjs.extend(customParseFormat); + + const { durationMinutes, searchRange, workHours } = constraints; + const d = (iso) => dayjs.utc(iso); + const durationMs = durationMinutes * 60 * 1000; + + const mergedBusy = mergeBusySlots( + [...calendar1, ...calendar2].map((s) => ({ start: d(s.start), end: d(s.end) })) + ); + + const rangeStart = d(searchRange.start); + const rangeEnd = d(searchRange.end); + + const freeSlots = extractFreeSlots(mergedBusy, rangeStart, rangeEnd); + + return freeSlots.flatMap((free) => + generateSlots(free.start, free.end, durationMs, workHours, dayjs) + ); +} + +function mergeBusySlots(slots) { + if (!slots.length) return []; + + const sorted = slots.slice().sort((a, b) => a.start.valueOf() - b.start.valueOf()); + + return sorted.reduce((merged, curr) => { + if (!merged.length) return [{ ...curr }]; + const last = merged[merged.length - 1]; + if (curr.start.valueOf() <= last.end.valueOf()) { + last.end = curr.end.valueOf() > last.end.valueOf() ? curr.end : last.end; + } else { + merged.push({ ...curr }); + } + return merged; + }, []); +} + +function extractFreeSlots(busySlots, rangeStart, rangeEnd) { + const free = []; + let cursor = rangeStart; + + for (const busy of busySlots) { + if (busy.start.valueOf() > cursor.valueOf()) { + const freeEnd = busy.start.valueOf() < rangeEnd.valueOf() ? busy.start : rangeEnd; + if (freeEnd.valueOf() > cursor.valueOf()) { + free.push({ start: cursor, end: freeEnd }); + } + } + if (busy.end.valueOf() > cursor.valueOf()) { + cursor = busy.end; + } + if (cursor.valueOf() >= rangeEnd.valueOf()) break; + } + + if (cursor.valueOf() < rangeEnd.valueOf()) { + free.push({ start: cursor, end: rangeEnd }); + } + + return free; +} + +function generateSlots(freeStart, freeEnd, durationMs, workHours, dayjs) { + const [whStartH, whStartM] = workHours.start.split(":").map(Number); + const [whEndH, whEndM] = workHours.end.split(":").map(Number); + const slots = []; + + let dayDate = freeStart.utc().startOf("day"); + const lastDay = freeEnd.utc().startOf("day"); + + while (dayDate.valueOf() <= lastDay.valueOf()) { + const wStart = dayDate.hour(whStartH).minute(whStartM).second(0).millisecond(0); + const wEnd = dayDate.hour(whEndH).minute(whEndM).second(0).millisecond(0); + + const slotStart = Math.max(freeStart.valueOf(), wStart.valueOf()); + const slotEnd = Math.min(freeEnd.valueOf(), wEnd.valueOf()); + + let cursor = alignToSlot(slotStart, wStart.valueOf(), durationMs); + + while (cursor + durationMs <= slotEnd) { + slots.push({ + start: dayjs.utc(cursor).toISOString(), + end: dayjs.utc(cursor + durationMs).toISOString(), + }); + cursor += durationMs; + } + + dayDate = dayDate.add(1, "day"); + } + + return slots; +} + +function alignToSlot(ts, workDayStart, durationMs) { + const offset = ts - workDayStart; + const remainder = offset % durationMs; + return remainder === 0 ? ts : ts + (durationMs - remainder); +} +export default findAvailableSlots; +// Generation time: 13.592s +// Result: FAIL \ No newline at end of file diff --git a/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.6.js b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..122d6dc --- /dev/null +++ b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,23 @@ +async function validateJSON(data, schema) { + const CDN = "https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv2020.min.js"; + + const module = await import(CDN); + const Ajv = module.default ?? module; + + const ajv = new Ajv({ allErrors: true, strict: false }); + const validate = ajv.compile(schema); + const valid = validate(data); + + return { + valid, + errors: valid + ? [] + : validate.errors.map( + ({ instancePath, message, params }) => + `${instancePath || "root"}: ${message} ${JSON.stringify(params)}` + ), + }; +} +export default validateJSON; +// Generation time: 3.415s +// Result: FAIL \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.6.js b/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.6.js new file mode 100644 index 0000000..784058b --- /dev/null +++ b/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.6.js @@ -0,0 +1,31 @@ +async function createStreamVisualizer(asyncIterable, options) { + const { maxPoints, alpha, width, height, yDomain } = options; + const { scaleLinear, line } = await import("https://cdn.skypack.dev/d3"); + + 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 = scaleLinear() + .domain([data[0].timestamp, data[data.length - 1].timestamp]) + .range([0, width]); + + const yScale = scaleLinear() + .domain(yDomain) + .range([height, 0]); + + const path = line() + .x(d => xScale(d.timestamp)) + .y(d => yScale(d.ema))(data); + + return { data, path }; +} +export default createStreamVisualizer; +// Generation time: 3.557s +// Result: PASS \ No newline at end of file