From 542af993bf7c193585b5ccad02c3cf480b4d497e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 18 May 2026 02:58:30 +0000 Subject: [PATCH] Docs: Update benchmark for openai/gpt-5.5 EFF:high --- .../outputs/openai_gpt-5.5 EFF_high.js | 24 ++++ .../outputs/openai_gpt-5.5 EFF_high.js | 19 +++ .../outputs/openai_gpt-5.5 EFF_high.js | 85 ++++++++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 43 ++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 34 +++++ .../outputs/openai_gpt-5.5 EFF_high.js | 76 +++++++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 70 ++++++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 25 ++++ .../outputs/openai_gpt-5.5 EFF_high.js | 34 +++++ .../outputs/openai_gpt-5.5 EFF_high.js | 127 ++++++++++++++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 101 ++++++++++++++ .../outputs/openai_gpt-5.5 EFF_high.js | 76 +++++++++++ 12 files changed, 714 insertions(+) create mode 100644 tests/10_scrypt_hash/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/11_geospatial/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/12_mst_pipeline/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/1_dijkstra/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/2_convex_hull/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/3_signal_pipeline/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/4_hexchain_pipeline/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/5_markdown_parser/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/6_csv_processor/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/7_scheduler/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/8_json_validator/outputs/openai_gpt-5.5 EFF_high.js create mode 100644 tests/9_stream_visualizer/outputs/openai_gpt-5.5 EFF_high.js diff --git a/tests/10_scrypt_hash/outputs/openai_gpt-5.5 EFF_high.js b/tests/10_scrypt_hash/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..394e2c7 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,24 @@ +const SCRYPT_CDN = 'https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm'; + +async function hashPassword(password, salt) { + if (typeof password !== 'string' || typeof salt !== 'string') + throw new TypeError('password and salt must be strings'); + + const { scrypt } = await import(SCRYPT_CDN); + const enc = new TextEncoder(); + const hash = await scrypt( + enc.encode(password), + enc.encode(salt), + 1024, + 8, + 1, + 32 + ); + + return [...hash] + .map(b => b.toString(16).padStart(2, '0')) + .join(''); +} +export default hashPassword; +// Generation time: 12.627s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/openai_gpt-5.5 EFF_high.js b/tests/11_geospatial/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..0d23da0 --- /dev/null +++ b/tests/11_geospatial/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,19 @@ +async function analyzeGPS(readings, boundary) { + const turf = await import("https://esm.sh/@turf/turf@7.2.0"); + + const valid = readings + .filter(({ loc }) => + turf.booleanPointInPolygon(turf.point(loc), boundary, { ignoreBoundary: true }) + ) + .sort((a, b) => a.ts - b.ts); + + if (valid.length < 2) return 0; + + const line = turf.lineString(valid.map(({ loc }) => loc)); + const km = turf.length(line, { units: "kilometers" }); + + return +km.toFixed(2); +} +export default analyzeGPS; +// Generation time: 13.413s +// Result: PASS \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/openai_gpt-5.5 EFF_high.js b/tests/12_mst_pipeline/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..9df7e71 --- /dev/null +++ b/tests/12_mst_pipeline/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,85 @@ +const mstDeps = () => mstDeps.p ??= Promise.all([ + import('https://esm.sh/smol-toml'), + import('https://esm.sh/mnemonist/heap'), + import('https://esm.sh/text-table') +]).then(([toml, heap, text]) => ({ + parse: toml.parse ?? toml.default?.parse ?? toml.default, + Heap: heap.default ?? heap.Heap ?? heap, + table: text.default ?? text.table ?? text +})); + +class UnionFind { + constructor(nodes) { + this.p = new Map; + this.r = new Map; + for (const n of nodes) { + this.p.set(n, n); + this.r.set(n, 0); + } + } + + find(x) { + let p = this.p.get(x); + if (p !== x) this.p.set(x, p = this.find(p)); + return p; + } + + union(a, b) { + let x = this.find(a), y = this.find(b); + if (x === y) return false; + + let rx = this.r.get(x), ry = this.r.get(y); + if (rx < ry) [x, y] = [y, x], [rx, ry] = [ry, rx]; + + this.p.set(y, x); + if (rx === ry) this.r.set(x, rx + 1); + return true; + } +} + +async function computeMST(input) { + if (typeof input !== 'string') throw new TypeError('Expected a TOML string'); + + const {parse, Heap, table} = await mstDeps(); + const {edges: raw} = parse(input); + + if (!Array.isArray(raw)) throw new TypeError('Expected TOML to contain an edges array'); + + const nodes = new Set; + const edges = raw.map((e, i) => { + const from = e?.from, to = e?.to, weight = Number(e?.weight); + + if (typeof from !== 'string' || typeof to !== 'string' || !Number.isFinite(weight)) { + throw new TypeError(`Invalid edge at index ${i}`); + } + + nodes.add(from); + nodes.add(to); + return {from, to, weight, i}; + }); + + const heap = new Heap((a, b) => a.weight - b.weight || a.i - b.i); + for (const e of edges) heap.push(e); + + const uf = new UnionFind(nodes); + const mst = []; + let totalWeight = 0, left = edges.length; + + while (mst.length < nodes.size - 1 && left) { + left--; + + const e = heap.pop(); + if (!uf.union(e.from, e.to)) continue; + + mst.push([e.from, e.to, String(e.weight)]); + totalWeight += e.weight; + } + + return { + table: table([['From', 'To', 'Weight'], ...mst]), + totalWeight + }; +} +export default computeMST; +// Generation time: 47.382s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/openai_gpt-5.5 EFF_high.js b/tests/1_dijkstra/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..27f70ef --- /dev/null +++ b/tests/1_dijkstra/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,43 @@ +const loadPQ = (() => { + let p; + + return () => p ||= import("https://esm.sh/js-priority-queue@0.1.5") + .then(m => m.default?.default ?? m.default ?? m.PriorityQueue); +})(); + +async function findShortestPath(graph, start, end) { + const PriorityQueue = await loadPQ(); + const dist = new Map([[start, 0]]); + const q = new PriorityQueue({ + comparator: (a, b) => a.cost - b.cost + }); + + q.queue({ node: start, cost: 0 }); + + while (q.length) { + const { node, cost } = q.dequeue(); + + if (cost > dist.get(node)) continue; + if (node === end) return cost; + + for (const [next, rawWeight] of Object.entries(graph?.[node] ?? {})) { + const weight = Number(rawWeight); + + if (!Number.isFinite(weight) || weight < 0) { + throw new RangeError("Edge weights must be finite non-negative numbers"); + } + + const nextCost = cost + weight; + + if (nextCost < (dist.get(next) ?? Infinity)) { + dist.set(next, nextCost); + q.queue({ node: next, cost: nextCost }); + } + } + } + + return Infinity; +} +export default findShortestPath; +// Generation time: 55.807s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/openai_gpt-5.5 EFF_high.js b/tests/2_convex_hull/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..3cd58ec --- /dev/null +++ b/tests/2_convex_hull/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,34 @@ +const findConvexHull = async points => { + const { sortBy, uniqBy } = await import( + "https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js" + ) + + const pts = uniqBy( + sortBy(points, ["x", "y"]), + p => `${p.x}\u0000${p.y}` + ) + + if (pts.length < 2) return pts + + const cross = (a, b, c) => + (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) + + const half = arr => { + const h = [] + + for (const p of arr) { + while (h.length > 1 && cross(h.at(-2), h.at(-1), p) <= 0) h.pop() + h.push(p) + } + + return h + } + + return [ + ...half(pts).slice(0, -1), + ...half([...pts].reverse()).slice(0, -1) + ] +} +export default findConvexHull; +// Generation time: 14.673s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/openai_gpt-5.5 EFF_high.js b/tests/3_signal_pipeline/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..b0997f4 --- /dev/null +++ b/tests/3_signal_pipeline/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,76 @@ +async function analyzeSignal(yamlString) { + const [ + yamlMod, + math, + ndarrayMod, + fftMod, + purifyMod + ] = await Promise.all([ + import("https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm"), + import("https://cdn.jsdelivr.net/npm/mathjs@13.2.0/+esm"), + import("https://cdn.jsdelivr.net/npm/ndarray@1.0.19/+esm"), + import("https://cdn.jsdelivr.net/npm/ndarray-fft@1.0.3/+esm"), + import("https://cdn.jsdelivr.net/npm/dompurify@3.1.6/+esm") + ]); + + const yaml = yamlMod.default || yamlMod; + const ndarray = ndarrayMod.default || ndarrayMod; + const fft = fftMod.default || fftMod; + const DOMPurify = purifyMod.default || purifyMod; + + const cfg = yaml.load(yamlString); + const sampleRate = Number(cfg.sampleRate); + const duration = Number(cfg.duration); + const components = Array.isArray(cfg.components) ? cfg.components : []; + const N = Math.max(0, Math.floor(sampleRate * duration)); + + if (!Number.isFinite(sampleRate) || sampleRate <= 0) throw new Error("Invalid sampleRate"); + if (!Number.isFinite(duration) || duration <= 0) throw new Error("Invalid duration"); + if (!N) throw new Error("Signal length must be greater than zero"); + + const signal = Float64Array.from({ length: N }, (_, i) => { + const t = i / sampleRate; + + return components.reduce((sum, c) => { + const a = Number(c.amplitude); + const f = Number(c.frequency); + + return Number.isFinite(a) && Number.isFinite(f) + ? sum + a * math.sin(2 * math.pi * f * t) + : sum; + }, 0); + }); + + const real = ndarray(signal.slice(), [N]); + const imag = ndarray(new Float64Array(N), [N]); + + fft(1, real, imag); + + const peaks = Array.from({ length: Math.floor(N / 2) + 1 }, (_, k) => { + const re = real.get(k); + const im = imag.get(k); + const magnitude = math.sqrt(re ** 2 + im ** 2) / (N / 2); + + return { + frequencyHz: Math.round(k * sampleRate / N), + magnitude: Math.round(magnitude * 100) / 100, + rawMagnitude: magnitude + }; + }) + .filter(p => p.rawMagnitude > 0.1) + .sort((a, b) => b.rawMagnitude - a.rawMagnitude) + .map(({ frequencyHz, magnitude }) => ({ frequencyHz, magnitude })); + + const rows = peaks + .map(p => `${p.frequencyHz}${p.magnitude}`) + .join(""); + + const html = DOMPurify.sanitize( + `${rows}
Frequency (Hz)Magnitude
` + ); + + return { peaks, html, signalLength: N }; +} +export default analyzeSignal; +// Generation time: 16.732s +// Result: PASS \ No newline at end of file diff --git a/tests/4_hexchain_pipeline/outputs/openai_gpt-5.5 EFF_high.js b/tests/4_hexchain_pipeline/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..a947280 --- /dev/null +++ b/tests/4_hexchain_pipeline/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,70 @@ +const hexchainUrls = [ + 'https://esm.sh/smol-toml?bundle', + 'https://esm.sh/seedrandom?bundle', + 'https://esm.sh/simple-statistics?bundle', + 'https://esm.sh/ajv?bundle', + 'https://esm.sh/text-table?bundle', + 'https://esm.sh/dompurify?bundle' +]; + +const hexchainSchema = { + type: 'object', + required: ['seed', 'count', 'label'], + properties: { + seed: { type: 'string' }, + count: { type: 'integer', minimum: 1, maximum: 10000 }, + label: { type: 'string', minLength: 1 } + } +}; + +let hexchainModules; + +async function hexchain(tomlString) { + const [ + toml, + seedMod, + ssMod, + ajvMod, + tableMod, + purifyMod + ] = await (hexchainModules ||= Promise.all(hexchainUrls.map(u => import(u)))); + + const parse = toml.parse ?? toml.default?.parse ?? toml.default; + const seedrandom = seedMod.default ?? seedMod; + const ss = ssMod.mean ? ssMod : ssMod.default; + const Ajv = ajvMod.default ?? ajvMod.Ajv; + const textTable = tableMod.default ?? tableMod; + const purify = purifyMod.default ?? purifyMod; + const DOMPurify = purify.sanitize ? purify : purify(globalThis); + const config = parse(tomlString); + const ajv = new Ajv(); + + if (!ajv.validate(hexchainSchema, config)) + return { valid: false, errors: ajv.errorsText() }; + + const rng = new seedrandom(config.seed); + const nums = Array.from({ length: config.count }, () => rng()); + const round = n => Math.round((n + Number.EPSILON) * 1e6) / 1e6; + const mean = round(ss.mean(nums)); + const stddev = round(ss.standardDeviation(nums)); + const median = round(ss.median(nums)); + const tableString = textTable([ + ['Stat', 'Value'], + ['mean', String(mean)], + ['stddev', String(stddev)], + ['median', String(median)] + ]); + + return { + valid: true, + label: config.label, + stats: { mean, stddev, median }, + table: DOMPurify.sanitize('
' + tableString + '
'), + count: config.count + }; +} + +globalThis.hexchain = hexchain; +export default hexchain; +// Generation time: 137.860s +// Result: PASS \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openai_gpt-5.5 EFF_high.js b/tests/5_markdown_parser/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..3c7056b --- /dev/null +++ b/tests/5_markdown_parser/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,25 @@ +const parseMarkdown = (() => { + let libs; + + return async markdown => { + libs ||= Promise.all([ + import("https://cdn.jsdelivr.net/npm/marked@13/+esm"), + import("https://cdn.jsdelivr.net/npm/dompurify@3/+esm") + ]); + + const [{ marked }, { default: DOMPurify }] = await libs; + + marked.use({ + gfm: true, + breaks: false, + async: false + }); + + return DOMPurify.sanitize( + marked.parse(String(markdown ?? "")) + ); + }; +})(); +export default parseMarkdown; +// Generation time: 13.490s +// Result: PASS \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openai_gpt-5.5 EFF_high.js b/tests/6_csv_processor/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..1578643 --- /dev/null +++ b/tests/6_csv_processor/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,34 @@ +const csvDeps = Promise.all([ + import("https://cdn.jsdelivr.net/npm/d3-dsv@3/+esm"), + import("https://cdn.jsdelivr.net/npm/d3-array@3/+esm") +]); + +async function processCSV(csv, config = {}) { + const [{ csvParse }, { rollups }] = await csvDeps; + const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config; + const ops = new Set(["sum", "avg", "count"]); + + if (!ops.has(operation)) throw new TypeError("Invalid operation"); + + const num = r => { + const n = Number(r[aggregateColumn]); + return Number.isFinite(n) ? n : 0; + }; + + const rows = csvParse(String(csv ?? "")) + .filter(r => r[filterColumn] == filterValue); + + return rollups( + rows, + rs => { + if (operation === "count") return rs.length; + + const sum = rs.reduce((a, r) => a + num(r), 0); + return operation === "avg" ? sum / rs.length : sum; + }, + r => r[groupBy] + ).map(([k, result]) => ({ [groupBy]: k, result })); +} +export default processCSV; +// Generation time: 26.121s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/openai_gpt-5.5 EFF_high.js b/tests/7_scheduler/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..cc3ea63 --- /dev/null +++ b/tests/7_scheduler/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,127 @@ +let luxonPromise; + +async function findAvailableSlots(calendarA = [], calendarB = [], constraints = {}) { + const { DateTime } = await (luxonPromise ||= import("https://esm.sh/luxon@3.5.0?bundle")); + const M = 6e4, D = 864e5; + const err = (E, m) => { throw new E(m); }; + + const toMs = v => { + if (typeof v !== "string") err(TypeError, `Invalid ISO date: ${v}`); + const d = DateTime.fromISO(v, { zone: "utc" }); + if (!d.isValid) err(TypeError, `Invalid ISO date: ${v}`); + return d.toUTC().toMillis(); + }; + + const toMinutes = v => { + if (typeof v !== "string") err(TypeError, `Invalid UTC time: ${v}`); + const m = /^(\d{2}):(\d{2})$/.exec(v); + if (!m) err(TypeError, `Invalid UTC time: ${v}`); + + const h = +m[1], n = +m[2]; + if (h > 24 || n > 59 || h === 24 && n) + err(RangeError, `Invalid UTC time: ${v}`); + + return h * 60 + n; + }; + + if (!Array.isArray(calendarA) || !Array.isArray(calendarB)) + err(TypeError, "Calendars must be arrays"); + + if (!constraints || typeof constraints !== "object" || Array.isArray(constraints)) + err(TypeError, "Constraints must be an object"); + + if (typeof constraints.durationMinutes !== "number") + err(TypeError, "durationMinutes must be a number"); + + const duration = constraints.durationMinutes * M; + if (!Number.isFinite(duration) || duration <= 0 || !Number.isInteger(duration)) + err(RangeError, "durationMinutes must resolve to a positive whole millisecond value"); + + const rangeStart = toMs(constraints.searchRange?.start); + const rangeEnd = toMs(constraints.searchRange?.end); + + if (rangeEnd <= rangeStart) + err(RangeError, "searchRange.end must be after searchRange.start"); + + const workStart = toMinutes(constraints.workHours?.start); + const workEnd = toMinutes(constraints.workHours?.end); + + if (workStart === 1440) + err(RangeError, "workHours.start must be before 24:00"); + + const midnight = ms => DateTime.fromMillis(ms, { zone: "utc" }).startOf("day").toMillis(); + const overnight = workEnd <= workStart; + const work = []; + + const addWork = (s, e) => { + const a = Math.max(s, rangeStart), b = Math.min(e, rangeEnd); + if (a >= b) return; + + const l = work[work.length - 1]; + if (l && a <= l[1]) l[1] = Math.max(l[1], b); + else work.push([a, b]); + }; + + for ( + let d = midnight(rangeStart) - (overnight ? D : 0), end = midnight(rangeEnd); + d <= end; + d += D + ) + addWork(d + workStart * M, d + workEnd * M + (overnight ? D : 0)); + + const busy = calendarA.concat(calendarB) + .map(slot => { + if (!slot || typeof slot !== "object") + err(TypeError, "Busy slots must be objects"); + + const s = toMs(slot.start), e = toMs(slot.end); + if (e <= s) err(RangeError, "Busy slot end must be after start"); + + return [Math.max(s, rangeStart), Math.min(e, rangeEnd)]; + }) + .filter(([s, e]) => s < e) + .sort((a, b) => a[0] - b[0] || a[1] - b[1]); + + const merged = []; + + for (const [s, e] of busy) { + const l = merged[merged.length - 1]; + if (l && s <= l[1]) l[1] = Math.max(l[1], e); + else merged.push([s, e]); + } + + const slots = []; + const addSlots = (s, e) => { + for (; s + duration <= e; s += duration) + slots.push([s, s + duration]); + }; + + let i = 0; + + for (const [ws, we] of work) { + while (merged[i]?.[1] <= ws) i++; + + let p = ws; + + for (let j = i; merged[j]?.[0] < we; j++) { + const [bs, be] = merged[j]; + + if (bs > p) addSlots(p, Math.min(bs, we)); + + p = Math.max(p, Math.min(be, we)); + if (p >= we) break; + } + + if (p < we) addSlots(p, we); + } + + const iso = ms => DateTime.fromMillis(ms, { zone: "utc" }).toISO(); + + return slots.map(([start, end]) => ({ + start: iso(start), + end: iso(end) + })); +} +export default findAvailableSlots; +// Generation time: 263.158s +// Result: PASS \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openai_gpt-5.5 EFF_high.js b/tests/8_json_validator/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..4a2332c --- /dev/null +++ b/tests/8_json_validator/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,101 @@ +const _jsonSchema = (() => { + const ajvs = new Map(); + const vals = new WeakMap(); + const opts = { + allErrors: true, + strict: false, + allowUnionTypes: true, + addUsedSchema: false, + validateFormats: true + }; + + const ver = s => { + s = `${s && typeof s == "object" && s.$schema || ""}`; + return s.includes("2020-12") ? "2020" : s.includes("2019-09") ? "2019" : "7"; + }; + + const url = v => `https://esm.sh/ajv@8.17.1${v == "7" ? "" : `/dist/${v}`}?bundle`; + + const load = v => { + let p = ajvs.get(v); + if (p) return p; + + p = Promise.all([ + import(url(v)), + import("https://esm.sh/ajv-formats@3.0.1?bundle&deps=ajv@8.17.1") + ]).then(([a, f]) => { + const Ajv = a.default || a.Ajv || a; + const addFormats = f.default || f.addFormats || f; + const ajv = new Ajv({ ...opts }); + addFormats(ajv); + return ajv; + }).catch(e => { + ajvs.delete(v); + throw e; + }); + + ajvs.set(v, p); + return p; + }; + + const part = s => /^(0|[1-9]\d*)$/.test(s) + ? `[${s}]` + : /^[A-Za-z_$][\w$]*$/.test(s) + ? `.${s}` + : `[${JSON.stringify(s)}]`; + + const loc = p => p + ? `$${p.split("/").slice(1).map(s => part(s.replace(/~1/g, "/").replace(/~0/g, "~"))).join("")}` + : "$"; + + const msg = e => { + const x = e.params || {}; + const extra = e.keyword == "additionalProperties" + ? `: ${x.additionalProperty}` + : e.keyword == "required" + ? `: ${x.missingProperty}` + : ""; + + return `${loc(e.instancePath)} ${e.message || "is invalid"}${extra}`; + }; + + return { load, vals, ver, msg }; +})(); + +async function validateJSON(data, schema) { + const isSchema = typeof schema == "boolean" || + schema && typeof schema == "object" && !Array.isArray(schema); + + if (!isSchema) { + return { + valid: false, + errors: ["Schema must be a JSON Schema object or boolean"] + }; + } + + try { + const cacheable = schema && typeof schema == "object"; + let validate = cacheable && _jsonSchema.vals.get(schema); + + if (!validate) { + const ajv = await _jsonSchema.load(_jsonSchema.ver(schema)); + validate = ajv.compile(schema); + if (cacheable) _jsonSchema.vals.set(schema, validate); + } + + const valid = validate(data); + + return { + valid, + errors: valid ? [] : (validate.errors || []).map(_jsonSchema.msg) + }; + } catch (e) { + return { + valid: false, + errors: [e?.message || String(e)] + }; + } +} +export default validateJSON; +// Generation time: 143.247s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/openai_gpt-5.5 EFF_high.js b/tests/9_stream_visualizer/outputs/openai_gpt-5.5 EFF_high.js new file mode 100644 index 0000000..c50585f --- /dev/null +++ b/tests/9_stream_visualizer/outputs/openai_gpt-5.5 EFF_high.js @@ -0,0 +1,76 @@ +const d3$ = import("https://cdn.jsdelivr.net/npm/d3@7/+esm"); + +async function createStreamVisualizer(asyncIterable, options = {}) { + const { + maxPoints, + alpha, + width, + height, + yDomain + } = options; + + if (!asyncIterable?.[Symbol.asyncIterator]) + throw new TypeError("asyncIterable must be an async iterable"); + + if (!Number.isInteger(maxPoints) || maxPoints < 1) + throw new RangeError("maxPoints must be a positive integer"); + + if (!Number.isFinite(alpha) || alpha < 0 || alpha > 1) + throw new RangeError("alpha must be between 0 and 1"); + + if (!Number.isFinite(width) || width <= 0 || !Number.isFinite(height) || height <= 0) + throw new RangeError("width and height must be positive numbers"); + + if (!Array.isArray(yDomain) || yDomain.length !== 2) + throw new TypeError("yDomain must be [min, max]"); + + const [yMin, yMax] = yDomain.map(Number); + + if (!Number.isFinite(yMin) || !Number.isFinite(yMax) || yMin === yMax) + throw new RangeError("yDomain values must be finite and distinct"); + + const d3 = await d3$; + const data = []; + let ema; + + for await (const item of asyncIterable) { + const source = Array.isArray(item) + ? { timestamp: item[0], value: item[1] } + : item; + + const timestamp = +source?.timestamp; + const value = +source?.value; + + if (!Number.isFinite(timestamp) || !Number.isFinite(value)) + throw new TypeError("stream items must include finite timestamp and value"); + + ema = ema === undefined + ? value + : alpha * value + (1 - alpha) * ema; + + data.push({ timestamp, value, ema }); + + if (data.length > maxPoints) + data.splice(0, data.length - maxPoints); + } + + if (!data.length) + return { data, path: "" }; + + const x = d3.scaleLinear() + .domain([data[0].timestamp, data.at(-1).timestamp]) + .range([0, width]); + + const y = d3.scaleLinear() + .domain([yMin, yMax]) + .range([height, 0]); + + const path = d3.line() + .x(d => x(d.timestamp)) + .y(d => y(d.ema))(data) || ""; + + return { data, path }; +} +export default createStreamVisualizer; +// Generation time: 27.168s +// Result: PASS \ No newline at end of file