From 9a649978848ce821f8b4b06ad089a10d58455c17 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 14 Nov 2025 03:31:28 +0000 Subject: [PATCH] Docs: Update benchmark results --- results.json | 68 +++++----- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 6 +- .../outputs/google_gemini-2.5-pro.js | 35 +++--- .../1_dijkstra/outputs/openai_gpt-5.1-chat.js | 23 ++++ .../outputs/openai_gpt-5.1-codex.js | 23 ++++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 5 +- .../outputs/google_gemini-2.5-pro.js | 39 +++--- .../outputs/openai_gpt-5.1-chat.js | 28 ++--- .../outputs/openai_gpt-5.1-codex.js | 18 +++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 7 +- tests/3_lis/outputs/google_gemini-2.5-pro.js | 12 +- tests/3_lis/outputs/openai_gpt-5.1-chat.js | 10 +- tests/3_lis/outputs/openai_gpt-5.1-codex.js | 13 +- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 4 +- .../outputs/google_gemini-2.5-pro.js | 4 +- .../outputs/openai_gpt-5.1-chat.js | 2 +- .../outputs/openai_gpt-5.1-codex.js | 4 +- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 6 +- .../outputs/google_gemini-2.5-pro.js | 8 +- .../outputs/openai_gpt-5.1-chat.js | 5 +- .../outputs/openai_gpt-5.1-codex.js | 8 +- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 38 +++--- .../outputs/google_gemini-2.5-pro.js | 63 +++++----- .../outputs/openai_gpt-5.1-chat.js | 22 ++++ .../outputs/openai_gpt-5.1-codex.js | 33 +++-- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 116 ++++++++++-------- .../outputs/google_gemini-2.5-pro.js | 70 +++++++++++ .../outputs/openai_gpt-5.1-chat.js | 70 +++++------ .../outputs/openai_gpt-5.1-codex.js | 95 +++++++------- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 14 ++- .../outputs/google_gemini-2.5-pro.js | 34 ++--- .../outputs/openai_gpt-5.1-chat.js | 12 +- .../outputs/openai_gpt-5.1-codex.js | 15 ++- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 30 +++++ .../outputs/google_gemini-2.5-pro.js | 60 +++++++++ .../outputs/openai_gpt-5.1-chat.js | 23 ++++ .../outputs/openai_gpt-5.1-codex.js | 23 ++++ 37 files changed, 656 insertions(+), 390 deletions(-) create mode 100644 tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js create mode 100644 tests/1_dijkstra/outputs/openai_gpt-5.1-codex.js create mode 100644 tests/2_convex_hull/outputs/openai_gpt-5.1-codex.js create mode 100644 tests/6_csv_processor/outputs/openai_gpt-5.1-chat.js create mode 100644 tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js create mode 100644 tests/9_stream_visualizer/outputs/google_gemini-2.5-pro.js create mode 100644 tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js create mode 100644 tests/9_stream_visualizer/outputs/openai_gpt-5.1-codex.js diff --git a/results.json b/results.json index 5ad0582..6a84764 100644 --- a/results.json +++ b/results.json @@ -1,42 +1,46 @@ { "openai/gpt-5.1-codex": { - "1_dijkstra": null, - "2_convex_hull": null, - "3_lis": 4.134811772999999, - "4_determinant": 3.128456531999999, - "5_markdown_parser": 2.4388916820000004, - "6_csv_processor": 43.478935838999995, - "7_scheduler": 84.317196593, - "8_json_validator": 6.765057070999989 + "1_dijkstra": 15.241279893, + "2_convex_hull": 13.933983282, + "3_lis": 3.980165064000001, + "4_determinant": 6.332550646999996, + "5_markdown_parser": 3.2380716380000014, + "6_csv_processor": 26.09038364200001, + "7_scheduler": 130.18603798900003, + "8_json_validator": 8.38715121099999, + "9_stream_visualizer": 12.031535295999987 }, "openai/gpt-5.1-chat": { - "1_dijkstra": null, - "2_convex_hull": 4.03333652099999, - "3_lis": 3.2548832980000006, - "4_determinant": 3.480435989999998, - "5_markdown_parser": 12.157845766999992, - "6_csv_processor": null, - "7_scheduler": 3.6146848039999897, - "8_json_validator": 3.9886151490000192 + "1_dijkstra": 2.65463601799999, + "2_convex_hull": 3.1764218759999787, + "3_lis": 2.5808361240000233, + "4_determinant": 1.857067280999996, + "5_markdown_parser": 2.1500550130000047, + "6_csv_processor": 2.8134082990000024, + "7_scheduler": 6.116577822999999, + "8_json_validator": 1.477971265, + "9_stream_visualizer": 1.7076946140000073 }, "google/gemini-2.5-pro": { - "1_dijkstra": 44.864160204000015, - "2_convex_hull": 33.892027145, - "3_lis": 36.906535906, - "4_determinant": 11.497210719000025, - "5_markdown_parser": 13.62311761299998, - "6_csv_processor": 42.61058959099999, - "7_scheduler": 12.12732526100002, - "8_json_validator": 50.54006011399999 + "1_dijkstra": 33.989065073000006, + "2_convex_hull": 56.566219838000016, + "3_lis": 52.14045403000002, + "4_determinant": 14.913826469999972, + "5_markdown_parser": 26.86344819299999, + "6_csv_processor": 49.397067434999975, + "7_scheduler": 52.55558026300004, + "8_json_validator": 19.59284627099999, + "9_stream_visualizer": 36.41860035799991 }, "anthropic/claude-sonnet-4.5 TEMP:0.7": { - "1_dijkstra": 4.8069697199999935, - "2_convex_hull": 4.475060508999974, - "3_lis": 2.835424330000009, - "4_determinant": 2.3172859399999726, - "5_markdown_parser": 2.080127800999966, - "6_csv_processor": 5.218456623000034, - "7_scheduler": 11.33699588100001, - "8_json_validator": 3.298284380999976 + "1_dijkstra": 4.49742717099993, + "2_convex_hull": 4.570548665000009, + "3_lis": 2.375867489000084, + "4_determinant": 1.5574152070001, + "5_markdown_parser": 1.8310976730000694, + "6_csv_processor": 4.079893573999987, + "7_scheduler": 12.446870330999955, + "8_json_validator": 2.8953664760000537, + "9_stream_visualizer": 5.022439357000054 } } \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index de03834..b0feb33 100644 --- a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,15 +1,15 @@ async function findShortestPath(graph, start, end) { - const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm'); + const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm'); const distances = Object.keys(graph).reduce((acc, node) => ({ ...acc, [node]: Infinity }), {}); distances[start] = 0; - const pq = new PQ({ comparator: (a, b) => a.dist - b.dist }); + const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist }); pq.queue({ node: start, dist: 0 }); const visited = new Set(); - while (pq.length) { + while (pq.length > 0) { const { node, dist } = pq.dequeue(); if (visited.has(node)) continue; diff --git a/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js b/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js index a6c489c..fa539e2 100644 --- a/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js +++ b/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js @@ -1,33 +1,36 @@ -async function findShortestPath(graph, start, end) { +const findShortestPath = async (graph, startNode, endNode) => { const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'); const distances = Object.fromEntries( - Object.keys(graph).map(node => [node, Infinity]) + Object.keys(graph).map(node => [node, 1 / 0]) ); - distances[start] = 0; + distances[startNode] = 0; const pq = new PriorityQueue({ - comparator: (a, b) => distances[b] - distances[a] + comparator: (a, b) => a.priority - b.priority }); - pq.queue(start); + pq.queue({ node: startNode, priority: 0 }); while (pq.length) { - const currentNode = pq.dequeue(); + const { node: u, priority: dist } = pq.dequeue(); - if (currentNode === end) break; + if (dist > distances[u]) { + continue; + } - if (!graph[currentNode]) continue; + if (u === endNode) { + break; + } - for (const [neighbor, weight] of Object.entries(graph[currentNode])) { - const newDist = distances[currentNode] + weight; - - if (newDist < distances[neighbor]) { - distances[neighbor] = newDist; - pq.queue(neighbor); + for (const [v, weight] of Object.entries(graph[u] ?? {})) { + const newDist = distances[u] + weight; + if (newDist < distances[v]) { + distances[v] = newDist; + pq.queue({ node: v, priority: newDist }); } } } - return distances[end]; -} + return distances[endNode]; +}; export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js b/tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js new file mode 100644 index 0000000..1280658 --- /dev/null +++ b/tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js @@ -0,0 +1,23 @@ +async function findShortestPath(g,s,e){ + const {default:Q}=await import('https://cdn.jsdelivr.net/npm/js-priority-queue@latest/dist/priority-queue.min.js') + const d={},v={} + for(const k in g)d[k]=Infinity + d[s]=0 + const q=new Q({comparator:(a,b)=>a[1]-b[1]}) + q.queue([s,0]) + while(q.length){ + const [n,w]=q.dequeue() + if(v[n])continue + v[n]=1 + if(n===e)return w + for(const k in g[n]){ + const nw=w+g[n][k] + if(nw{ + if(s===t)return 0 + const{default:PriorityQueue}=await import('https://cdn.skypack.dev/js-priority-queue') + if(!g[s]||!g[t])return Infinity + const seen=new Map([[s,0]]) + const pq=new PriorityQueue({comparator:(a,b)=>a[1]-b[1]}) + pq.queue([s,0]) + while(pq.length){ + const[n,d]=pq.dequeue() + if(d>(seen.get(n)??Infinity))continue + if(n===t)return d + const nbrs=g[n]||{} + for(const k in nbrs){ + const nd=d+nbrs[k] + if(nd<(seen.get(k)??Infinity)){ + seen.set(k,nd) + pq.queue([k,nd]) + } + } + } + return Infinity +} +export default findShortestPath; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 9a7b132..ce472a4 100644 --- a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -21,6 +21,9 @@ async function findConvexHull(points) { return hull; }; - return [...buildHull(sorted), ...buildHull([...sorted].reverse())]; + const lower = buildHull(sorted); + const upper = buildHull([...sorted].reverse()); + + return [...lower, ...upper]; } export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js b/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js index 00f59ee..2271a65 100644 --- a/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js +++ b/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js @@ -1,28 +1,29 @@ const findConvexHull = async (points) => { - const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js'); + const { sortBy, uniqWith, isEqual } = + await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js'); - const sortedPoints = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']); + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); - if (sortedPoints.length < 3) { - return sortedPoints; + const pts = sortBy(uniqWith(points, isEqual), ['x', 'y']); + + if (pts.length < 3) return pts; + + const lower = []; + for (const p of pts) { + while (lower.length >= 2 && cross(lower.at(-2), lower.at(-1), p) <= 0) { + lower.pop(); + } + lower.push(p); } - const crossProduct = (p1, p2, p3) => - (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); - - const buildHalfHull = (pointSet) => { - const hull = []; - for (const p of pointSet) { - while (hull.length >= 2 && crossProduct(hull.at(-2), hull.at(-1), p) <= 0) { - hull.pop(); - } - hull.push(p); + const upper = []; + for (let i = pts.length - 1; i >= 0; i--) { + const p = pts[i]; + while (upper.length >= 2 && cross(upper.at(-2), upper.at(-1), p) <= 0) { + upper.pop(); } - return hull; - }; - - const lower = buildHalfHull(sortedPoints); - const upper = buildHalfHull([...sortedPoints].reverse()); + upper.push(p); + } return [...lower.slice(0, -1), ...upper.slice(0, -1)]; }; diff --git a/tests/2_convex_hull/outputs/openai_gpt-5.1-chat.js b/tests/2_convex_hull/outputs/openai_gpt-5.1-chat.js index 9d0520f..e2b91bb 100644 --- a/tests/2_convex_hull/outputs/openai_gpt-5.1-chat.js +++ b/tests/2_convex_hull/outputs/openai_gpt-5.1-chat.js @@ -1,20 +1,20 @@ -export async function findConvexHull(a){ - const _ = (await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js')).default - a = _.uniqWith(a,_.isEqual) - a = _.sortBy(a,['x','y']) - const c=(o,p,q)=>((p.x-o.x)*(q.y-o.y)-(p.y-o.y)*(q.x-o.x)) - const b=[] - for(const p of a){ - while(b.length>1 && c(b[b.length-2],b[b.length-1],p)<=0) b.pop() - b.push(p) +export async function findConvexHull(p){ + const _=(await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js')).default + p=_.uniqWith(p,_.isEqual) + p=_.sortBy(p,['x','y']) + const c=(a,b,d)=>(b.x-a.x)*(d.y-a.y)-(b.y-a.y)*(d.x-a.x) + const h=[] + for(const v of p){ + while(h.length>1&&c(h[h.length-2],h[h.length-1],v)<=0)h.pop() + h.push(v) } const u=[] - for(const p of [...a].reverse()){ - while(u.length>1 && c(u[u.length-2],u[u.length-1],p)<=0) u.pop() - u.push(p) + for(const v of [...p].reverse()){ + while(u.length>1&&c(u[u.length-2],u[u.length-1],v)<=0)u.pop() + u.push(v) } + h.pop() u.pop() - b.pop() - return [...b,...u] + return [...h,...u] } export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/openai_gpt-5.1-codex.js b/tests/2_convex_hull/outputs/openai_gpt-5.1-codex.js new file mode 100644 index 0000000..1ce745a --- /dev/null +++ b/tests/2_convex_hull/outputs/openai_gpt-5.1-codex.js @@ -0,0 +1,18 @@ +async function findConvexHull(points) { + const {sortBy, uniqWith} = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js') + const ps = uniqWith(sortBy(points.map(({x, y}) => ({x: +x, y: +y})), ['x', 'y']), (a, b) => a.x === b.x && a.y === b.y) + if (ps.length < 2) return ps + const c = (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 ps) { + while (lower.length > 1 && c(lower.at(-2), lower.at(-1), p) <= 0) lower.pop() + lower.push(p) + } + const upper = [] + for (const p of [...ps].reverse()) { + while (upper.length > 1 && c(upper.at(-2), upper.at(-1), p) <= 0) upper.pop() + upper.push(p) + } + return lower.slice(0, -1).concat(upper.slice(0, -1)) +} +export default findConvexHull; \ No newline at end of file diff --git a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 3e87752..0920907 100644 --- a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,13 +1,12 @@ const findLISLength = async (arr) => { if (!arr?.length) return 0; - const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm'); - + const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); const tails = []; for (const num of arr) { - const pos = bisectLeft(tails, num); - tails[pos] = num; + const idx = bisectLeft(tails, num); + tails[idx] = num; } return tails.length; diff --git a/tests/3_lis/outputs/google_gemini-2.5-pro.js b/tests/3_lis/outputs/google_gemini-2.5-pro.js index 304fe96..e6ea665 100644 --- a/tests/3_lis/outputs/google_gemini-2.5-pro.js +++ b/tests/3_lis/outputs/google_gemini-2.5-pro.js @@ -1,12 +1,16 @@ -async function findLISLength(nums) { - const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm'); +const findLISLength = async (nums) => { + if (!nums?.length) { + return 0; + } + + const { bisectLeft } = await import('https://esm.sh/d3-array'); const tails = []; - for (const num of nums || []) { + for (const num of nums) { tails[bisectLeft(tails, num)] = num; } return tails.length; -} +}; export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/openai_gpt-5.1-chat.js b/tests/3_lis/outputs/openai_gpt-5.1-chat.js index 9200c26..9962564 100644 --- a/tests/3_lis/outputs/openai_gpt-5.1-chat.js +++ b/tests/3_lis/outputs/openai_gpt-5.1-chat.js @@ -1,10 +1,10 @@ async function findLISLength(a) { - const {bisectLeft:b} = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm') - const t = [] + const {bisectLeft} = await import("https://cdn.jsdelivr.net/npm/d3-array@3/+esm"); + const t = []; for (const x of a) { - const i = b(t, x) - t[i] = x + const i = bisectLeft(t, x); + t[i] = x; } - return t.length + return t.length; } export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/openai_gpt-5.1-codex.js b/tests/3_lis/outputs/openai_gpt-5.1-codex.js index 4ece4d6..9b88a0c 100644 --- a/tests/3_lis/outputs/openai_gpt-5.1-codex.js +++ b/tests/3_lis/outputs/openai_gpt-5.1-codex.js @@ -1,10 +1,7 @@ -async function findLISLength(nums){ - const {bisectLeft}=await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm') - const tails=[] - for(const n of nums){ - const i=bisectLeft(tails,n) - tails[i]=n - } - return tails.length +async function findLISLength(a){ + const {bisectLeft:b}=await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm') + const t=[] + for(const n of a)t[b(t,n)]=n + return t.length } export default findLISLength; \ No newline at end of file diff --git a/tests/4_determinant/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/4_determinant/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 020003b..58e14ae 100644 --- a/tests/4_determinant/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/4_determinant/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,5 +1,5 @@ -async function calculateDeterminant(matrix) { +const calculateDeterminant = async (matrix) => { const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm'); return det(matrix); -} +}; export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/google_gemini-2.5-pro.js b/tests/4_determinant/outputs/google_gemini-2.5-pro.js index 9019d30..2c9565f 100644 --- a/tests/4_determinant/outputs/google_gemini-2.5-pro.js +++ b/tests/4_determinant/outputs/google_gemini-2.5-pro.js @@ -1,5 +1,5 @@ -const calculateDeterminant = async matrix => { - const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@12.4.2/es/index.js'); +const calculateDeterminant = async (matrix) => { + const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@13.0.0/+esm'); return det(matrix); }; export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/openai_gpt-5.1-chat.js b/tests/4_determinant/outputs/openai_gpt-5.1-chat.js index 9908892..776a2ca 100644 --- a/tests/4_determinant/outputs/openai_gpt-5.1-chat.js +++ b/tests/4_determinant/outputs/openai_gpt-5.1-chat.js @@ -1,5 +1,5 @@ async function calculateDeterminant(m){ - const {det}=await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm') + const {det}=await import('https://cdn.jsdelivr.net/npm/mathjs@14.0.0/+esm') return det(m) } export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/openai_gpt-5.1-codex.js b/tests/4_determinant/outputs/openai_gpt-5.1-codex.js index 9908892..5cbc3ee 100644 --- a/tests/4_determinant/outputs/openai_gpt-5.1-codex.js +++ b/tests/4_determinant/outputs/openai_gpt-5.1-codex.js @@ -1,5 +1,5 @@ -async function calculateDeterminant(m){ - const {det}=await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm') +const calculateDeterminant=async m=>{ + const {det}=await import('https://cdn.skypack.dev/mathjs') return det(m) } export default calculateDeterminant; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 41ba4bb..9bf74ee 100644 --- a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,5 +1,5 @@ -async function parseMarkdown(md) { - const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11/+esm'); +const parseMarkdown = async (md) => { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm'); return marked.parse(md); -} +}; export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/google_gemini-2.5-pro.js b/tests/5_markdown_parser/outputs/google_gemini-2.5-pro.js index 62477fb..c692ded 100644 --- a/tests/5_markdown_parser/outputs/google_gemini-2.5-pro.js +++ b/tests/5_markdown_parser/outputs/google_gemini-2.5-pro.js @@ -1,6 +1,6 @@ -const parseMarkdown = async (md) => { - const cdn = 'https://cdn.jsdelivr.net/npm/marked@13.0.0/lib/marked.esm.js'; - const { marked } = await import(cdn); - return marked.parse(md); +const parseMarkdown = async (markdown) => { + const cdnUrl = 'https://cdn.jsdelivr.net/npm/marked@13.0.0/lib/marked.esm.js'; + const { marked } = await import(cdnUrl); + return marked.parse(markdown ?? ''); }; export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openai_gpt-5.1-chat.js b/tests/5_markdown_parser/outputs/openai_gpt-5.1-chat.js index 00db97f..ddbc499 100644 --- a/tests/5_markdown_parser/outputs/openai_gpt-5.1-chat.js +++ b/tests/5_markdown_parser/outputs/openai_gpt-5.1-chat.js @@ -1,2 +1,5 @@ - +export async function parseMarkdown(m){ + const {marked}=await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js') + return marked.parse(m) +} export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openai_gpt-5.1-codex.js b/tests/5_markdown_parser/outputs/openai_gpt-5.1-codex.js index d8f9b46..d9611bf 100644 --- a/tests/5_markdown_parser/outputs/openai_gpt-5.1-codex.js +++ b/tests/5_markdown_parser/outputs/openai_gpt-5.1-codex.js @@ -1,5 +1,5 @@ -const parseMarkdown = async m => { - const { marked } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js') - return marked.parse(m) -} +const parseMarkdown=async(md='')=>{ + const{marked}=await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js'); + return marked.parse(md); +}; export default parseMarkdown; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 2399256..bf8bb8e 100644 --- a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,32 +1,24 @@ -async function processCSV(csvString, config) { - const { parse } = await import('https://cdn.skypack.dev/papaparse@5.4.1'); +const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => { + const { parse } = await import('https://cdn.skypack.dev/csv-parse/sync'); - const { data } = parse(csvString, { header: true, skipEmptyLines: true }); + const records = parse(csv, { columns: true, skip_empty_lines: true }); - const filtered = data.filter(row => - String(row[config.filterColumn]) === String(config.filterValue) - ); + const filtered = records.filter(r => r[filterColumn] == filterValue); - const grouped = filtered.reduce((acc, row) => { - const key = row[config.groupBy]; - if (!acc[key]) acc[key] = []; - acc[key].push(row); + const groups = filtered.reduce((acc, row) => { + const key = row[groupBy]; + (acc[key] ??= []).push(row); return acc; }, {}); - return Object.entries(grouped).map(([key, rows]) => { - let result; - const vals = rows.map(r => parseFloat(r[config.aggregateColumn]) || 0); + return Object.entries(groups).map(([key, rows]) => { + const vals = rows.map(r => Number(r[aggregateColumn]) || 0); + const sum = vals.reduce((a, b) => a + b, 0); - if (config.operation === 'sum') { - result = vals.reduce((a, b) => a + b, 0); - } else if (config.operation === 'avg') { - result = vals.reduce((a, b) => a + b, 0) / vals.length; - } else { - result = rows.length; - } - - return { [config.groupBy]: key, result }; + return { + [groupBy]: key, + result: operation === 'sum' ? sum : operation === 'avg' ? sum / vals.length : vals.length + }; }); -} +}; export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/google_gemini-2.5-pro.js b/tests/6_csv_processor/outputs/google_gemini-2.5-pro.js index ed2244b..51dea76 100644 --- a/tests/6_csv_processor/outputs/google_gemini-2.5-pro.js +++ b/tests/6_csv_processor/outputs/google_gemini-2.5-pro.js @@ -1,44 +1,39 @@ -async function processCSV(csvString, config) { - const { - filterColumn, - filterValue, - groupBy, - aggregateColumn, - operation, - } = config; +async function processCSV(csv, { + filterColumn, + filterValue, + groupBy, + aggregateColumn, + operation, +}) { + const { default: Papa } = await import( + 'https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js' + ); - const { default: Papa } = await import('https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js'); + const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true }); - const { data } = Papa.parse(csvString, { - header: true, - dynamicTyping: true, - skipEmptyLines: true, - }); + const groups = data.reduce((acc, row) => { + if (row[filterColumn] != filterValue) { + return acc; + } + + const key = row[groupBy]; + const stats = acc.get(key) || { sum: 0, count: 0 }; + + stats.sum += Number(row[aggregateColumn]) || 0; + stats.count++; + + return acc.set(key, stats); + }, new Map()); const aggregators = { - sum: (acc, val) => (acc || 0) + val, - count: (acc, _val) => (acc || 0) + 1, - avg: (acc, val) => { - const state = acc || { sum: 0, count: 0 }; - state.sum += val; - state.count += 1; - return state; - }, + sum: ({ sum }) => sum, + avg: ({ sum, count }) => (count ? sum / count : 0), + count: ({ count }) => count, }; - const groups = data - .filter(row => row[filterColumn] == filterValue) - .reduce((acc, row) => { - const key = row[groupBy]; - acc[key] = aggregators[operation](acc[key], row[aggregateColumn]); - return acc; - }, {}); - - return Object.entries(groups).map(([key, value]) => ({ + return Array.from(groups, ([key, stats]) => ({ [groupBy]: key, - result: operation === 'avg' - ? (value.count ? value.sum / value.count : 0) - : value, + result: aggregators[operation](stats), })); } export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openai_gpt-5.1-chat.js b/tests/6_csv_processor/outputs/openai_gpt-5.1-chat.js new file mode 100644 index 0000000..31c4d81 --- /dev/null +++ b/tests/6_csv_processor/outputs/openai_gpt-5.1-chat.js @@ -0,0 +1,22 @@ +async function processCSV(csv, cfg) { + const p = await import("https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js"); + const f = p.parse(csv, { header: true }).data.filter(r => r[cfg.filterColumn] == cfg.filterValue); + const g = {}; + for (const r of f) { + const k = r[cfg.groupBy]; + if (!g[k]) g[k] = []; + g[k].push(r); + } + const out = []; + for (const k in g) { + const rows = g[k]; + let nums = rows.map(r => +r[cfg.aggregateColumn] || 0); + let res = 0; + if (cfg.operation === "sum") res = nums.reduce((a, b) => a + b, 0); + else if (cfg.operation === "avg") res = nums.reduce((a, b) => a + b, 0) / nums.length; + else if (cfg.operation === "count") res = rows.length; + out.push({ [cfg.groupBy]: k, result: res }); + } + return out; +} +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openai_gpt-5.1-codex.js b/tests/6_csv_processor/outputs/openai_gpt-5.1-codex.js index ba7aa9b..fd1786d 100644 --- a/tests/6_csv_processor/outputs/openai_gpt-5.1-codex.js +++ b/tests/6_csv_processor/outputs/openai_gpt-5.1-codex.js @@ -1,21 +1,16 @@ -const libs=(()=>{let c;return()=>c||(c=Promise.all([ -import('https://cdn.jsdelivr.net/npm/d3-dsv@3/+esm'), -import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/groupBy.js') -]).then(([dsv,gb])=>({parse:dsv.csvParse,groupBy:gb.default||gb})));})(); - -const toNum=v=>{const n=+v;return Number.isFinite(n)?n:0}; - -async function processCSV(csv,opts){ - const {parse,groupBy}=await libs(); - const rows=parse(csv); - const {filterColumn:fc,filterValue:fv,groupBy:gc,aggregateColumn:ac,operation:op}=opts; - const pool=groupBy(rows.filter(r=>r[fc]==fv),r=>r[gc]??''); - const calc={ - sum:x=>x.reduce((t,r)=>t+toNum(r[ac]),0), - avg:x=>x.length?x.reduce((t,r)=>t+toNum(r[ac]),0)/x.length:0, - count:x=>x.length - }[op]; - if(!calc) throw new Error('Unsupported operation'); - return Object.entries(pool).map(([k,x])=>({[gc]:k,result:calc(x)})); +async function processCSV(csv,cfg){ + const [{Papa},{groupBy:gb}]=await Promise.all([ + import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.mjs'), + import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js') + ]) + const {filterColumn:fc,filterValue:fv,groupBy:gbk,aggregateColumn:ac,operation:op}=cfg + const rows=Papa.parse(csv,{header:!0,skipEmptyLines:!0}).data.filter(r=>r&&r[fc]==fv) + const grouped=gb(rows,r=>r?.[gbk]??'') + return Object.entries(grouped).map(([k,arr])=>{ + const nums=arr.map(r=>{const n=+r[ac];return Number.isFinite(n)?n:0}) + const sum=nums.reduce((a,b)=>a+b,0) + const result=op==='sum'?sum:op==='avg'?sum/nums.length:arr.length + return {[gbk]:k,result} + }) } export default processCSV; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 8b530e9..b07f872 100644 --- a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,71 +1,81 @@ -const findAvailableSlots = async (cal1, cal2, constraints) => { - const { default: dayjs } = await import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/+esm'); - const [{ default: utc }, { default: isBetween }] = await Promise.all([ - import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/utc.js/+esm'), - import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/isBetween.js/+esm') - ]); +async function findAvailableSlots(cal1, cal2, constraints) { + const { parse, format, addMinutes, isWithinInterval, isBefore, isAfter, startOfDay, setHours, setMinutes } = await import('https://cdn.jsdelivr.net/npm/date-fns@3.0.0/+esm'); - dayjs.extend(utc); - dayjs.extend(isBetween); - const { durationMinutes, searchRange, workHours } = constraints; - const [whStart, whEnd] = [workHours.start.split(':'), workHours.end.split(':')]; + const duration = durationMinutes; - const merged = [...cal1, ...cal2] - .map(s => ({ start: dayjs(s.start), end: dayjs(s.end) })) - .sort((a, b) => a.start - b.start); + const parseTime = (dateStr) => parse(dateStr, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx", new Date()); + const toISO = (date) => format(date, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"); - const busy = merged.reduce((acc, curr) => { - if (!acc.length || curr.start > acc[acc.length - 1].end) { - acc.push(curr); + const rangeStart = parseTime(searchRange.start); + const rangeEnd = parseTime(searchRange.end); + + const [whStart, whEnd] = workHours.start.split(':').map(Number); + const [whEndH, whEndM] = workHours.end.split(':').map(Number); + + const allBusy = [...cal1, ...cal2].map(slot => ({ + start: parseTime(slot.start), + end: parseTime(slot.end) + })).sort((a, b) => a.start - b.start); + + const merged = []; + for (const slot of allBusy) { + if (!merged.length || isBefore(merged[merged.length - 1].end, slot.start)) { + merged.push({ ...slot }); } else { - acc[acc.length - 1].end = dayjs.max(acc[acc.length - 1].end, curr.end); + merged[merged.length - 1].end = isAfter(slot.end, merged[merged.length - 1].end) + ? slot.end + : merged[merged.length - 1].end; } - return acc; - }, []); - + } + + const freePeriods = []; + let current = rangeStart; + + for (const busy of merged) { + if (isBefore(current, busy.start)) { + freePeriods.push({ start: current, end: busy.start }); + } + current = isAfter(busy.end, current) ? busy.end : current; + } + + if (isBefore(current, rangeEnd)) { + freePeriods.push({ start: current, end: rangeEnd }); + } + + const isInWorkHours = (date) => { + const day = startOfDay(date); + const workStart = setMinutes(setHours(day, whStart), whEnd > 0 ? 0 : 0); + const workEnd = setMinutes(setHours(day, whEndH), whEndM); + return isWithinInterval(date, { start: workStart, end: workEnd }); + }; + const slots = []; - let current = dayjs(searchRange.start); - const rangeEnd = dayjs(searchRange.end); - - while (current < rangeEnd) { - const dayStart = current.hour(+whStart[0]).minute(+whStart[1]).second(0); - const dayEnd = current.hour(+whEnd[0]).minute(+whEnd[1]).second(0); + + for (const period of freePeriods) { + let slotStart = period.start; - let slotStart = dayStart < current ? current : dayStart; - - for (const b of busy) { - if (b.end <= slotStart || b.start >= dayEnd) continue; + while (true) { + const slotEnd = addMinutes(slotStart, duration); - if (b.start > slotStart) { - const slotEnd = dayjs.min(b.start, dayEnd); - let probe = slotStart; + if (isAfter(slotEnd, period.end)) break; + + if (isInWorkHours(slotStart) && isInWorkHours(slotEnd)) { + const day1 = startOfDay(slotStart); + const day2 = startOfDay(slotEnd); - while (probe.add(durationMinutes, 'minute') <= slotEnd) { + if (day1.getTime() === day2.getTime()) { slots.push({ - start: probe.toISOString(), - end: probe.add(durationMinutes, 'minute').toISOString() + start: toISO(slotStart), + end: toISO(slotEnd) }); - probe = probe.add(durationMinutes, 'minute'); } } - slotStart = dayjs.max(slotStart, b.end); + + slotStart = slotEnd; } - - if (slotStart < dayEnd) { - let probe = slotStart; - while (probe.add(durationMinutes, 'minute') <= dayEnd) { - slots.push({ - start: probe.toISOString(), - end: probe.add(durationMinutes, 'minute').toISOString() - }); - probe = probe.add(durationMinutes, 'minute'); - } - } - - current = current.add(1, 'day').startOf('day'); } - + return slots; -}; +} export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/google_gemini-2.5-pro.js b/tests/7_scheduler/outputs/google_gemini-2.5-pro.js index 2cb0879..1d65edf 100644 --- a/tests/7_scheduler/outputs/google_gemini-2.5-pro.js +++ b/tests/7_scheduler/outputs/google_gemini-2.5-pro.js @@ -1,2 +1,72 @@ +const findAvailableSlots = async (calendar1, calendar2, constraints) => { + const [{ default: dayjs }, { default: utc }] = await Promise.all([ + import('https://cdn.skypack.dev/dayjs'), + import('https://cdn.skypack.dev/dayjs/plugin/utc.js'), + ]); + dayjs.extend(utc); + const { durationMinutes, searchRange, workHours } = constraints; + + const toDayjs = (t) => dayjs.utc(t); + const toDayjsRange = ({ start, end }) => ({ start: toDayjs(start), end: toDayjs(end) }); + + const search = toDayjsRange(searchRange); + const allBusy = [...calendar1, ...calendar2] + .map(toDayjsRange) + .sort((a, b) => a.start.valueOf() - b.start.valueOf()); + + const mergedBusy = allBusy.reduce((acc, current) => { + const last = acc[acc.length - 1]; + if (last && current.start.valueOf() < last.end.valueOf()) { + if (current.end.isAfter(last.end)) { + last.end = current.end; + } + } else { + acc.push({ ...current }); + } + return acc; + }, []); + + const boundaryPoints = [ + search.start, + ...mergedBusy.flatMap(b => [b.start, b.end]), + search.end, + ]; + + const freeGaps = []; + for (let i = 0; i < boundaryPoints.length - 1; i += 2) { + const start = boundaryPoints[i]; + const end = boundaryPoints[i + 1]; + if (end.isAfter(start)) { + freeGaps.push({ start, end }); + } + } + + const availableSlots = []; + const [workStartH, workStartM] = workHours.start.split(':').map(Number); + const [workEndH, workEndM] = workHours.end.split(':').map(Number); + + for (const gap of freeGaps) { + let cursor = gap.start.startOf('day'); + while (cursor.isBefore(gap.end)) { + const workWindowStart = cursor.hour(workStartH).minute(workStartM); + const workWindowEnd = cursor.hour(workEndH).minute(workEndM); + + let effectiveStart = dayjs.max(gap.start, workWindowStart); + const effectiveEnd = dayjs.min(gap.end, workWindowEnd); + + while (effectiveStart.add(durationMinutes, 'minute').valueOf() <= effectiveEnd.valueOf()) { + const slotEnd = effectiveStart.add(durationMinutes, 'minute'); + availableSlots.push({ start: effectiveStart, end: slotEnd }); + effectiveStart = slotEnd; + } + cursor = cursor.add(1, 'day'); + } + } + + return availableSlots.map(({ start, end }) => ({ + start: start.toISOString(), + end: end.toISOString(), + })); +}; export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/openai_gpt-5.1-chat.js b/tests/7_scheduler/outputs/openai_gpt-5.1-chat.js index c330862..de770c6 100644 --- a/tests/7_scheduler/outputs/openai_gpt-5.1-chat.js +++ b/tests/7_scheduler/outputs/openai_gpt-5.1-chat.js @@ -1,48 +1,36 @@ async function findAvailableSlots(a,b,c){ - const d=await import('https://esm.sh/date-fns@3.6.0') - const {parseISO,formatISO,max,min,addMinutes,isBefore}=d - const p=t=>parseISO(t) - const wh=(dt,s)=>{ - const [H,M]=s.split(':') - const x=new Date(dt) - x.setHours(H,M,0,0) - return x + const f=await import('https://esm.sh/date-fns') + const p=f.parseISO,d=f.addMinutes,x=f.max,y=f.min,i=f.isBefore,j=f.isAfter + const {durationMinutes:r,searchRange:s,workHours:w}=c + const h=t=>t.split(':').map(n=>+n) + const [ws,we]=[h(w.start),h(w.end)] + const z=(d0,[H,M])=>{d0=new Date(d0);d0.setHours(H,M,0,0);return d0.toISOString()} + const S=p(s.start),E=p(s.end) + let u=[...a,...b].map(o=>({start:p(o.start),end:p(o.end)})) + u=u.sort((A,B)=>A.start-B.start) + let m=[] + for(let k of u){ + if(!m.length||k.start>m[m.length-1].end)m.push({start:k.start,end:k.end}) + else m[m.length-1].end=new Date(Math.max(m[m.length-1].end,k.end)) } - const rng=[p(c.searchRange.start),p(c.searchRange.end)] - const dur=c.durationMinutes - const norm=x=>x.map(v=>[p(v.start),p(v.end)]) - const A=norm(a),B=norm(b) - const merge=x=>{ - let r=x.sort((x,y)=>x[0]-y[0]),o=[r[0]] - for(let i=1;icur) free.push([cur,busy[i][0]]) - cur=max(cur,busy[i][1]) - }else free.push([s,e]) - } - const out=[] - for(let [s,e]of free){ - s=max(s,rng[0]) - e=min(e,rng[1]) - let ws=wh(s,c.workHours.start) - let we=wh(s,c.workHours.end) - if(ws>we){let t=ws;ws=we;we=t} - let ss=max(s,ws),ee=min(e,we) - while(isBefore(addMinutes(ss,dur),ee)){ - out.push({start:formatISO(ss),end:formatISO(addMinutes(ss,dur))}) - ss=addMinutes(ss,dur) + if(i(st,E))q.push({start:x(st,S),end:E}) + let out=[] + for(let v of q){ + let cs=z(v.start,ws),ce=z(v.start,we) + cs=p(cs);ce=p(ce) + let ss=x(v.start,cs),ee=y(v.end,ce) + for(let t=ss;i(d(t,r),ee)||+d(t,r)==+ee;t=d(t,r)){ + let e=d(t,r) + if(!j(t,ss)||i(e,ee))out.push({start:t.toISOString(),end:e.toISOString()}) } } return out diff --git a/tests/7_scheduler/outputs/openai_gpt-5.1-codex.js b/tests/7_scheduler/outputs/openai_gpt-5.1-codex.js index 65332b9..a91ace7 100644 --- a/tests/7_scheduler/outputs/openai_gpt-5.1-codex.js +++ b/tests/7_scheduler/outputs/openai_gpt-5.1-codex.js @@ -1,55 +1,52 @@ -const luxon=import('https://cdn.skypack.dev/luxon'); +let luxon$ -const findAvailableSlots=async(c1,c2,k)=>{ - const {DateTime}=await luxon; - const {durationMinutes:d,searchRange:r,workHours:w}=k; - const zone=DateTime.fromISO(r.start).zoneName; - const iso=v=>DateTime.fromISO(v,{zone}); - const rangeStart=iso(r.start); - const rangeEnd=iso(r.end); - if(rangeEnd<=rangeStart)return[]; - const [hs,ms]=w.start.split(':').map(Number); - const [he,me]=w.end.split(':').map(Number); - const daysEnd=rangeEnd.startOf('day'); - const windows=[]; - for(let day=rangeStart.startOf('day');day<=daysEnd;day=day.plus({days:1})){ - let s=day.set({hour:hs,minute:ms,second:0,millisecond:0}); - let e=day.set({hour:he,minute:me,second:0,millisecond:0}); - if(e<=s||e<=rangeStart||s>=rangeEnd)continue; - if(srangeEnd)e=rangeEnd; - windows.push({start:s,end:e}); +const findAvailableSlots = async (calA, calB, cfg) => { + const {DateTime, Interval} = await (luxon$ ||= import('https://cdn.skypack.dev/luxon')) + const {durationMinutes: d, searchRange: r, workHours: w} = cfg + const s = DateTime.fromISO(r.start) + const e = DateTime.fromISO(r.end) + const range = Interval.fromDateTimes(s, e) + const [sh, sm] = w.start.split(':').map(Number) + const [eh, em] = w.end.split(':').map(Number) + const busy = [...calA, ...calB] + .map(({start, end}) => ({start: DateTime.fromISO(start), end: DateTime.fromISO(end)})) + .filter(v => v.end > s && v.start < e) + .map(v => ({start: v.start < s ? s : v.start, end: v.end > e ? e : v.end})) + .sort((a, b) => a.start.valueOf() - b.start.valueOf()) + const merged = [] + for (const slot of busy) { + const last = merged.at(-1) + if (!last || slot.start > last.end) merged.push({...slot}) + else if (slot.end > last.end) last.end = slot.end } - if(!windows.length)return[]; - const busy=[...c1,...c2].map(v=>{ - let s=iso(v.start),e=iso(v.end); - if(e<=s||e<=rangeStart||s>=rangeEnd)return null; - if(srangeEnd)e=rangeEnd; - return{start:s,end:e}; - }).filter(Boolean).sort((a,b)=>a.start.valueOf()-b.start.valueOf()); - const merged=[]; - for(const slot of busy){ - const last=merged[merged.length-1]; - if(last&&slot.start<=last.end){ - if(slot.end>last.end)last.end=slot.end; - }else merged.push({start:slot.start,end:slot.end}); + const out = [] + const emit = (from, to) => { + if (!(to > from)) return + for (let st = from, en = st.plus({minutes: d}); en <= to; st = en, en = st.plus({minutes: d})) + out.push({start: st.toISO(), end: en.toISO()}) } - const out=[]; - const push=(s,e)=>e.diff(s,'minutes').minutes>=d&&out.push({start:s.toISO(),end:e.toISO()}); - for(const wSlot of windows){ - let cur=wSlot.start; - for(const b of merged){ - if(b.start>=wSlot.end)break; - if(b.end<=wSlot.start)continue; - const bs=b.start>wSlot.start?b.start:wSlot.start; - const be=b.endcur)push(cur,bs); - if(be>cur)cur=be; - if(cur>=wSlot.end)break; + let i = 0 + for (let day = s.startOf('day'); day < e; day = day.plus({days: 1})) { + const ws = day.set({hour: sh, minute: sm, second: 0, millisecond: 0}) + const we = day.set({hour: eh, minute: em, second: 0, millisecond: 0}) + const block = Interval.fromDateTimes(ws, we).intersection(range) + if (!block) continue + while (i < merged.length && merged[i].end <= block.start) i++ + let cursor = block.start + for (let j = i; j < merged.length && merged[j].start < block.end; j++) { + const bs = merged[j].start > block.start ? merged[j].start : block.start + if (bs > cursor) { + emit(cursor, bs) + cursor = bs + } + if (merged[j].end > cursor) { + const be = merged[j].end < block.end ? merged[j].end : block.end + cursor = be + } + if (cursor >= block.end) break } - if(cur { - const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.bundle.js'); - - const ajv = new Ajv({ allErrors: true, verbose: true }); + const { default: Ajv } = await import('https://esm.sh/ajv@8.12.0'); + const ajv = new Ajv({ allErrors: true }); const validate = ajv.compile(schema); const valid = validate(data); return { valid, - errors: valid ? [] : validate.errors.map(e => - `${e.instancePath || '/'} ${e.message}${e.params ? ': ' + JSON.stringify(e.params) : ''}` - ) + errors: valid ? [] : validate.errors.map(e => ({ + path: e.instancePath || '/', + message: e.message, + keyword: e.keyword, + params: e.params + })) }; }; export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/google_gemini-2.5-pro.js b/tests/8_json_validator/outputs/google_gemini-2.5-pro.js index 4bb7be3..5c85970 100644 --- a/tests/8_json_validator/outputs/google_gemini-2.5-pro.js +++ b/tests/8_json_validator/outputs/google_gemini-2.5-pro.js @@ -1,35 +1,17 @@ -const validateJSON = async (jsonObject, schemaObject) => { +const validateJSON = async (data, schema) => { try { - const [{ - default: Ajv - }, { - default: addFormats - }] = await Promise.all([ - import('https://esm.sh/ajv'), - import('https://esm.sh/ajv-formats') - ]); - - const ajv = new Ajv({ - allErrors: true - }); - addFormats(ajv); - - const validate = ajv.compile(schemaObject); - const valid = validate(jsonObject); - - const errors = valid ? [] : validate.errors.map( - e => `${e.instancePath || ''}: ${e.message}` - ); + const { default: Ajv } = await import('https://esm.sh/ajv@8'); + const validate = new Ajv({ allErrors: true }).compile(schema); + const valid = validate(data); return { valid, - errors + errors: valid ? [] : (validate.errors ?? []).map( + ({ instancePath, message }) => `${instancePath || 'root'} ${message}`.trim() + ), }; } catch (e) { - return { - valid: false, - errors: [`Validation setup failed: ${e.message}`] - }; + return { valid: false, errors: [e.message] }; } }; export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openai_gpt-5.1-chat.js b/tests/8_json_validator/outputs/openai_gpt-5.1-chat.js index 6c34e04..762d50b 100644 --- a/tests/8_json_validator/outputs/openai_gpt-5.1-chat.js +++ b/tests/8_json_validator/outputs/openai_gpt-5.1-chat.js @@ -1,8 +1,8 @@ -async function validateJSON(o, s) { - const { default: Ajv } = await import('https://esm.sh/ajv@8'); - const a = new Ajv({ allErrors: true }); - const v = a.compile(s); - const ok = v(o); - return { valid: ok, errors: ok ? [] : v.errors.map(e => e.message) }; +async function validateJSON(d,s){ + const {default:Ajv}=await import('https://cdn.skypack.dev/ajv'); + const a=new Ajv({allErrors:true}); + const v=a.compile(s); + const ok=v(d); + return{valid:ok,errors:ok?[]:(v.errors||[]).map(e=>e.message||'')}; } export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openai_gpt-5.1-codex.js b/tests/8_json_validator/outputs/openai_gpt-5.1-codex.js index 3f0adf3..ccd2b93 100644 --- a/tests/8_json_validator/outputs/openai_gpt-5.1-codex.js +++ b/tests/8_json_validator/outputs/openai_gpt-5.1-codex.js @@ -1,10 +1,9 @@ -const validateJSON=async(j,s)=>{ - const{default:Ajv}=await import('https://esm.sh/ajv@8') - const{default:f}=await import('https://esm.sh/ajv-formats@2') - const a=new Ajv({allErrors:1,strict:false}) - f(a) - const v=a.compile(s) - const ok=v(j) - return{valid:ok,errors:ok?[]:(v.errors||[]).map(e=>`${e.instancePath||'/'} ${e.message}`.trim())} +export async function validateJSON(data, schema) { + const { default: Ajv } = await import('https://esm.sh/ajv@8?bundle'); + const ajv = new Ajv({ allErrors: true, strict: false }); + const validate = ajv.compile(schema); + const valid = validate(data); + const errors = valid ? [] : (validate.errors || []).map(e => `${e.instancePath || '/'} ${e.message || ''}`.trim()); + return { valid, errors }; } export default validateJSON; \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js new file mode 100644 index 0000000..afd30db --- /dev/null +++ b/tests/9_stream_visualizer/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -0,0 +1,30 @@ +export 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; + + for await (const { timestamp, value } of asyncIterable) { + const ema = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma; + data.push({ timestamp, value, ema }); + if (data.length > maxPoints) data.shift(); + prevEma = ema; + } + + 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 path = d3.line() + .x(d => xScale(d.timestamp)) + .y(d => yScale(d.ema)) + (data); + + return { data, path }; +} +export default createStreamVisualizer; \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/google_gemini-2.5-pro.js b/tests/9_stream_visualizer/outputs/google_gemini-2.5-pro.js new file mode 100644 index 0000000..7d2c34d --- /dev/null +++ b/tests/9_stream_visualizer/outputs/google_gemini-2.5-pro.js @@ -0,0 +1,60 @@ +async function createStreamVisualizer(asyncIterable, { + maxPoints, + alpha, + width, + height, + yDomain +}) { + const { + scaleLinear, + line + } = await import('d3'); + + const data = []; + let prevEma = null; + + for await (const { + timestamp, + value + } of asyncIterable) { + const ema = prevEma === null ? + value : + alpha * value + (1 - alpha) * prevEma; + + data.push({ + timestamp, + value, + ema + }); + prevEma = ema; + + if (data.length > maxPoints) { + data.shift(); + } + } + + if (data.length < 2) { + 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]); + + const path = line() + .x(d => x(d.timestamp)) + .y(d => y(d.ema))(data); + + return { + data, + path + }; +} +export default createStreamVisualizer; \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js b/tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js new file mode 100644 index 0000000..a8e6957 --- /dev/null +++ b/tests/9_stream_visualizer/outputs/openai_gpt-5.1-chat.js @@ -0,0 +1,23 @@ +export async function createStreamVisualizer(iter, o) { + const { maxPoints, alpha, width, height, yDomain } = o + const d3 = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm') + const data = [] + let ema + for await (const { timestamp, value } of iter) { + ema = ema == null ? value : alpha * value + (1 - alpha) * ema + data.push({ timestamp, value, ema }) + if (data.length > maxPoints) data.shift() + } + const xs = d3.scaleLinear() + .domain([data[0].timestamp, data[data.length - 1].timestamp]) + .range([0, width]) + const ys = d3.scaleLinear() + .domain(yDomain) + .range([height, 0]) + const line = d3.line() + .x(d => xs(d.timestamp)) + .y(d => ys(d.ema)) + const path = line(data) || '' + return { data, path } +} +export default createStreamVisualizer; \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/openai_gpt-5.1-codex.js b/tests/9_stream_visualizer/outputs/openai_gpt-5.1-codex.js new file mode 100644 index 0000000..f33d3b1 --- /dev/null +++ b/tests/9_stream_visualizer/outputs/openai_gpt-5.1-codex.js @@ -0,0 +1,23 @@ +async function createStreamVisualizer(iterable, { + maxPoints = 100, + alpha = .5, + width = 300, + height = 150, + yDomain = [0, 1] +} = {}) { + const { scaleLinear, line } = await import('https://cdn.jsdelivr.net/npm/d3@7/+esm') + const data = [] + let ema + for await (const point of iterable) { + const { timestamp, value } = point + ema = ema == null ? value : alpha * value + (1 - alpha) * ema + data.push({ timestamp, value, ema }) + data.length > maxPoints && data.shift() + } + 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]) + const path = line().x(d => x(d.timestamp)).y(d => y(d.ema))(data) || '' + return { data, path } +} +export default createStreamVisualizer; \ No newline at end of file