mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for test 4
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
async function hexchain(tomlString) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
seedrandom,
|
||||||
|
ss,
|
||||||
|
Ajv,
|
||||||
|
table,
|
||||||
|
DOMPurify
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://esm.sh/smol-toml'),
|
||||||
|
import('https://esm.sh/seedrandom').then(m => m.default),
|
||||||
|
import('https://esm.sh/simple-statistics'),
|
||||||
|
import('https://esm.sh/ajv').then(m => m.default),
|
||||||
|
import('https://esm.sh/text-table').then(m => m.default),
|
||||||
|
import('https://esm.sh/dompurify').then(m => m.default)
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlString);
|
||||||
|
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) {
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const nums = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const r = n => Math.round(n * 1e6) / 1e6;
|
||||||
|
const mean = r(ss.mean(nums));
|
||||||
|
const stddev = r(ss.standardDeviation(nums));
|
||||||
|
const median = r(ss.median(nums));
|
||||||
|
|
||||||
|
const tableStr = table([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(mean)],
|
||||||
|
['stddev', String(stddev)],
|
||||||
|
['median', String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sanitizedHTML = DOMPurify.sanitize('<pre class="stats">' + tableStr + '</pre>');
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 6.766s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
async function hexchain(tomlString) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
seedrandomMod,
|
||||||
|
ss,
|
||||||
|
AjvMod,
|
||||||
|
textTable,
|
||||||
|
DOMPurify
|
||||||
|
] = await Promise.all([
|
||||||
|
import("https://cdn.jsdelivr.net/npm/smol-toml/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/seedrandom/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/simple-statistics/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/ajv/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/text-table/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/dompurify/+esm")
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlString);
|
||||||
|
|
||||||
|
const Ajv = AjvMod.default || AjvMod;
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: "object",
|
||||||
|
required: ["seed", "count", "label"],
|
||||||
|
properties: {
|
||||||
|
seed: { type: "string" },
|
||||||
|
count: { type: "integer", minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: "string", minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const valid = ajv.validate(schema, config);
|
||||||
|
if (!valid) return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const seedrandom = seedrandomMod.default || seedrandomMod;
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const nums = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const round6 = v => Math.round(v * 1e6) / 1e6;
|
||||||
|
const mean = round6(ss.mean(nums));
|
||||||
|
const stddev = round6(ss.standardDeviation(nums));
|
||||||
|
const median = round6(ss.median(nums));
|
||||||
|
|
||||||
|
const table = textTable.default || textTable;
|
||||||
|
const tableString = table([
|
||||||
|
["Stat", "Value"],
|
||||||
|
["mean", String(mean)],
|
||||||
|
["stddev", String(stddev)],
|
||||||
|
["median", String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const purify = DOMPurify.default || DOMPurify;
|
||||||
|
const sanitize = purify.sanitize || purify;
|
||||||
|
const sanitizedHTML = (typeof sanitize === "function" ? sanitize : purify.sanitize).call(purify, '<pre class="stats">' + tableString + "</pre>");
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 8.641s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
seedrandom,
|
||||||
|
stats,
|
||||||
|
Ajv,
|
||||||
|
textTable,
|
||||||
|
{ default: DOMPurify }
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://cdn.jsdelivr.net/npm/smol-toml@1/dist/index.mjs'),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/seedrandom@3/+esm').then(m => m.default),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/simple-statistics@7/+esm'),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.min.js').then(m => m.default),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/text-table@0.2.0/+esm').then(m => m.default),
|
||||||
|
import('https://cdn.jsdelivr.net/npm/dompurify@3/+esm')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlString);
|
||||||
|
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) {
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const numbers = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const mean = +stats.mean(numbers).toFixed(6);
|
||||||
|
const stddev = +stats.standardDeviation(numbers).toFixed(6);
|
||||||
|
const median = +stats.median(numbers).toFixed(6);
|
||||||
|
|
||||||
|
const tableString = textTable([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(mean)],
|
||||||
|
['stddev', String(stddev)],
|
||||||
|
['median', String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sanitizedHTML = DOMPurify.sanitize(`<pre class="stats">${tableString}</pre>`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 6.949s
|
||||||
|
// Result: FAIL
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
async function hexchain(tomlString) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: seedrandom },
|
||||||
|
ss,
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: textTable },
|
||||||
|
{ default: DOMPurify },
|
||||||
|
] = await Promise.all([
|
||||||
|
import("https://esm.sh/smol-toml"),
|
||||||
|
import("https://esm.sh/seedrandom"),
|
||||||
|
import("https://esm.sh/simple-statistics"),
|
||||||
|
import("https://esm.sh/ajv"),
|
||||||
|
import("https://esm.sh/text-table"),
|
||||||
|
import("https://esm.sh/dompurify"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlString);
|
||||||
|
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const validate = ajv.compile({
|
||||||
|
type: "object",
|
||||||
|
required: ["seed", "count", "label"],
|
||||||
|
properties: {
|
||||||
|
seed: { type: "string" },
|
||||||
|
count: { type: "integer", minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: "string", minLength: 1 },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!validate(config)) {
|
||||||
|
return { valid: false, errors: ajv.errorsText(validate.errors) };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const numbers = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const round6 = (n) => Math.round(n * 1e6) / 1e6;
|
||||||
|
const mean = round6(ss.mean(numbers));
|
||||||
|
const stddev = round6(ss.standardDeviation(numbers));
|
||||||
|
const median = round6(ss.median(numbers));
|
||||||
|
|
||||||
|
const tableString = textTable([
|
||||||
|
["Stat", "Value"],
|
||||||
|
["mean", String(mean)],
|
||||||
|
["stddev", String(stddev)],
|
||||||
|
["median", String(median)],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sanitizedHTML = DOMPurify.sanitize(
|
||||||
|
`<pre class="stats">${tableString}</pre>`
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 5.576s
|
||||||
|
// Result: PASS
|
||||||
53
tests/4_hexchain_pipeline/outputs/deepseek_deepseek-v3.2.js
Normal file
53
tests/4_hexchain_pipeline/outputs/deepseek_deepseek-v3.2.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
async function hexchain(tomlString) {
|
||||||
|
const cdn = 'https://esm.sh/';
|
||||||
|
const toml = await import(cdn + 'smol-toml');
|
||||||
|
const { default: seedrandom } = await import(cdn + 'seedrandom');
|
||||||
|
const ss = await import(cdn + 'simple-statistics');
|
||||||
|
const Ajv = (await import(cdn + 'ajv')).default;
|
||||||
|
const tt = await import(cdn + 'text-table');
|
||||||
|
const DOMPurify = await import(cdn + 'dompurify');
|
||||||
|
|
||||||
|
const config = toml.parse(tomlString);
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) {
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rng = seedrandom(config.seed);
|
||||||
|
const numbers = Array.from({ length: config.count }, () => rng());
|
||||||
|
const mean = parseFloat(ss.mean(numbers).toFixed(6));
|
||||||
|
const stddev = parseFloat(ss.standardDeviation(numbers).toFixed(6));
|
||||||
|
const median = parseFloat(ss.median(numbers).toFixed(6));
|
||||||
|
|
||||||
|
const tableArray = [
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', mean.toString()],
|
||||||
|
['stddev', stddev.toString()],
|
||||||
|
['median', median.toString()]
|
||||||
|
];
|
||||||
|
|
||||||
|
const tableString = tt.default(tableArray);
|
||||||
|
const html = `<pre class="stats">${tableString}</pre>`;
|
||||||
|
const sanitizedHTML = DOMPurify.sanitize(html);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 15.489s
|
||||||
|
// Result: FAIL
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
export async function hexchain(tomlInput) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: SeedRandom },
|
||||||
|
ss,
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: table },
|
||||||
|
{ default: DOMPurify }
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://cdn.skypack.dev/smol-toml'),
|
||||||
|
import('https://cdn.skypack.dev/seedrandom'),
|
||||||
|
import('https://cdn.skypack.dev/simple-statistics'),
|
||||||
|
import('https://cdn.skypack.dev/ajv'),
|
||||||
|
import('https://cdn.skypack.dev/text-table'),
|
||||||
|
import('https://cdn.skypack.dev/dompurify')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlInput);
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) {
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rng = new SeedRandom(config.seed);
|
||||||
|
const data = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const stats = {
|
||||||
|
mean: ss.mean(data).toFixed(6),
|
||||||
|
stddev: ss.standardDeviation(data).toFixed(6),
|
||||||
|
median: ss.median(data).toFixed(6)
|
||||||
|
};
|
||||||
|
|
||||||
|
const rows = [
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', stats.mean],
|
||||||
|
['stddev', stats.stddev],
|
||||||
|
['median', stats.median]
|
||||||
|
];
|
||||||
|
|
||||||
|
const tableStr = table(rows);
|
||||||
|
const html = `<pre class="stats">${tableStr}</pre>`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: Object.fromEntries(Object.entries(stats).map(([k, v]) => [k, Number(v)])),
|
||||||
|
table: DOMPurify.sanitize(html),
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 4.172s
|
||||||
|
// Result: FAIL
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
const hexchain = async (tomlInput) => {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: SeedRandom },
|
||||||
|
Stats,
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: textTable },
|
||||||
|
{ default: DOMPurifyFactory }
|
||||||
|
] = await Promise.all([
|
||||||
|
'smol-toml', 'seedrandom', 'simple-statistics', 'ajv', 'text-table', 'dompurify'
|
||||||
|
].map(lib => import(`https://esm.sh/${lib}`)));
|
||||||
|
|
||||||
|
const config = parse(tomlInput), ajv = new Ajv();
|
||||||
|
const validate = ajv.compile({
|
||||||
|
type: 'object', required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!validate(config)) return { valid: false, errors: ajv.errorsText(validate.errors) };
|
||||||
|
|
||||||
|
const rng = new SeedRandom(config.seed);
|
||||||
|
const data = Array.from({ length: config.count }, rng);
|
||||||
|
const fmt = n => Number(n.toFixed(6));
|
||||||
|
|
||||||
|
const stats = {
|
||||||
|
mean: fmt(Stats.mean(data)),
|
||||||
|
stddev: fmt(Stats.standardDeviation(data)),
|
||||||
|
median: fmt(Stats.median(data))
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableString = textTable([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(stats.mean)],
|
||||||
|
['stddev', String(stats.stddev)],
|
||||||
|
['median', String(stats.median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sanitizer = DOMPurifyFactory.sanitize ? DOMPurifyFactory : DOMPurifyFactory(window);
|
||||||
|
const html = sanitizer.sanitize(`<pre class="stats">${tableString}</pre>`);
|
||||||
|
|
||||||
|
return { valid: true, label: config.label, stats, table: html, count: config.count };
|
||||||
|
};
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 62.534s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
async function hexchain(tomlStr) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: SR },
|
||||||
|
{ mean, standardDeviation, median },
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: table },
|
||||||
|
{ default: purify }
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://esm.sh/smol-toml'),
|
||||||
|
import('https://esm.sh/seedrandom'),
|
||||||
|
import('https://esm.sh/simple-statistics'),
|
||||||
|
import('https://esm.sh/ajv'),
|
||||||
|
import('https://esm.sh/text-table'),
|
||||||
|
import('https://esm.sh/dompurify')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(tomlStr),
|
||||||
|
ajv = new Ajv(),
|
||||||
|
schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config))
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = new SR(config.seed),
|
||||||
|
data = Array.from({ length: config.count }, rng),
|
||||||
|
stats = {
|
||||||
|
mean: +mean(data).toFixed(6),
|
||||||
|
stddev: +standardDeviation(data).toFixed(6),
|
||||||
|
median: +median(data).toFixed(6)
|
||||||
|
},
|
||||||
|
tbl = table([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(stats.mean)],
|
||||||
|
['stddev', String(stats.stddev)],
|
||||||
|
['median', String(stats.median)]
|
||||||
|
]),
|
||||||
|
sanitized = purify.sanitize(`<pre class="stats">${tbl}</pre>`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats,
|
||||||
|
table: sanitized,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 2.335s
|
||||||
|
// Result: PASS
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
export async function hexchain(t) {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: SR },
|
||||||
|
{ mean, standardDeviation, median },
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: TT },
|
||||||
|
{ default: DP }
|
||||||
|
] = await Promise.all([
|
||||||
|
'smol-toml', 'seedrandom', 'simple-statistics', 'ajv', 'text-table', 'dompurify'
|
||||||
|
].map(m => import(`https://esm.sh/${m}`)));
|
||||||
|
|
||||||
|
const c = parse(t), a = new Ajv();
|
||||||
|
|
||||||
|
if (!a.validate({
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
}, c)) return { valid: false, errors: a.errorsText() };
|
||||||
|
|
||||||
|
const r = new SR(c.seed), n = Array.from({ length: c.count }, () => r());
|
||||||
|
const f = x => Number(x(n).toFixed(6));
|
||||||
|
const [m, s, d] = [mean, standardDeviation, median].map(f);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: c.label,
|
||||||
|
count: c.count,
|
||||||
|
stats: { mean: m, stddev: s, median: d },
|
||||||
|
table: DP.sanitize(`<pre class="stats">${TT([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(m)],
|
||||||
|
['stddev', String(s)],
|
||||||
|
['median', String(d)]
|
||||||
|
])}</pre>`)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 58.112s
|
||||||
|
// Result: PASS
|
||||||
64
tests/4_hexchain_pipeline/outputs/minimax_minimax-m2.5.js
Normal file
64
tests/4_hexchain_pipeline/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
export async function hexchain(toml) {
|
||||||
|
const [
|
||||||
|
{ default: parseToml },
|
||||||
|
{ default: SR },
|
||||||
|
{ default: ss },
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: tableFmt },
|
||||||
|
{ default: purify },
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://esm.sh/smol-toml'),
|
||||||
|
import('https://esm.sh/seedrandom'),
|
||||||
|
import('https://esm.sh/simple-statistics'),
|
||||||
|
import('https://esm.sh/ajv'),
|
||||||
|
import('https://esm.sh/text-table'),
|
||||||
|
import('https://esm.sh/dompurify'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parseToml(toml);
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const validate = ajv.compile({
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!validate(config))
|
||||||
|
return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = new SR(config.seed);
|
||||||
|
const nums = Array.from({ length: config.count }, () => rng());
|
||||||
|
|
||||||
|
const mean = ss.mean(nums);
|
||||||
|
const stddev = ss.standardDeviation(nums);
|
||||||
|
const median = ss.median(nums);
|
||||||
|
|
||||||
|
const r = (v) => Math.round(v * 1e6) / 1e6;
|
||||||
|
const meanR = r(mean);
|
||||||
|
const stddevR = r(stddev);
|
||||||
|
const medianR = r(median);
|
||||||
|
|
||||||
|
const table = tableFmt([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(meanR)],
|
||||||
|
['stddev', String(stddevR)],
|
||||||
|
['median', String(medianR)],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const html = '<pre class="stats">' + table + '</pre>';
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean: meanR, stddev: stddevR, median: medianR },
|
||||||
|
table: purify.sanitize(html),
|
||||||
|
count: config.count,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 139.541s
|
||||||
|
// Result: FAIL
|
||||||
26
tests/4_hexchain_pipeline/outputs/moonshotai_kimi-k2.5.js
Normal file
26
tests/4_hexchain_pipeline/outputs/moonshotai_kimi-k2.5.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const hexchain = async (t) => {
|
||||||
|
const [
|
||||||
|
{ parse },
|
||||||
|
{ default: s },
|
||||||
|
{ mean, standardDeviation, median },
|
||||||
|
{ default: A },
|
||||||
|
{ default: l },
|
||||||
|
{ default: D }
|
||||||
|
] = await Promise.all(['smol-toml', 'seedrandom', 'simple-statistics', 'ajv', 'text-table', 'dompurify'].map(p => import(`https://cdn.jsdelivr.net/npm/${p}/+esm`)));
|
||||||
|
const c = parse(t);
|
||||||
|
const v = { type: 'object', required: ['seed', 'count', 'label'], properties: { seed: { type: 'string' }, count: { type: 'integer', minimum: 1, maximum: 10000 }, label: { type: 'string', minLength: 1 } } };
|
||||||
|
const a = new A();
|
||||||
|
if (!a.validate(v, c)) return { valid: !1, errors: a.errorsText() };
|
||||||
|
const r = s(c.seed);
|
||||||
|
const n = Array.from({ length: c.count }, () => r());
|
||||||
|
const f = x => Math.round(x * 1e6) / 1e6;
|
||||||
|
const m = f(mean(n));
|
||||||
|
const d = f(standardDeviation(n, !1));
|
||||||
|
const e = f(median(n));
|
||||||
|
const h = l([['Stat', 'Value'], ['mean', String(m)], ['stddev', String(d)], ['median', String(e)]]);
|
||||||
|
const g = D.sanitize('<pre class="stats">' + h + '</pre>');
|
||||||
|
return { valid: !0, label: c.label, stats: { mean: m, stddev: d, median: e }, table: g, count: c.count };
|
||||||
|
};
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 175.601s
|
||||||
|
// Result: PASS
|
||||||
72
tests/4_hexchain_pipeline/outputs/openai_gpt-5.3-codex.js
Normal file
72
tests/4_hexchain_pipeline/outputs/openai_gpt-5.3-codex.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
async function hexchain(tomlString) {
|
||||||
|
try {
|
||||||
|
const [
|
||||||
|
tomlMod,
|
||||||
|
seedMod,
|
||||||
|
statsMod,
|
||||||
|
ajvMod,
|
||||||
|
tableMod,
|
||||||
|
purifyMod
|
||||||
|
] = await Promise.all([
|
||||||
|
import("https://cdn.jsdelivr.net/npm/smol-toml@1.3.1/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/seedrandom@3.0.5/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/simple-statistics@7.8.8/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/ajv@8.17.1/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/text-table@0.2.0/+esm"),
|
||||||
|
import("https://cdn.jsdelivr.net/npm/dompurify@3.1.6/+esm")
|
||||||
|
]);
|
||||||
|
|
||||||
|
const parseToml = tomlMod.parse ?? tomlMod.default?.parse ?? tomlMod.default;
|
||||||
|
const SeedRandom = seedMod.default ?? seedMod.seedrandom ?? seedMod;
|
||||||
|
const stats = statsMod.default ?? statsMod;
|
||||||
|
const table = tableMod.default ?? tableMod;
|
||||||
|
const Ajv = ajvMod.default ?? ajvMod.Ajv ?? ajvMod;
|
||||||
|
|
||||||
|
let DOMPurify = purifyMod.default ?? purifyMod;
|
||||||
|
if (typeof DOMPurify === "function" && !DOMPurify.sanitize) DOMPurify = DOMPurify(window);
|
||||||
|
|
||||||
|
const config = parseToml(tomlString);
|
||||||
|
const schema = {
|
||||||
|
type: "object",
|
||||||
|
required: ["seed", "count", "label"],
|
||||||
|
properties: {
|
||||||
|
seed: { type: "string" },
|
||||||
|
count: { type: "integer", minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: "string", minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const ajv = new Ajv();
|
||||||
|
if (!ajv.validate(schema, config)) return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = new SeedRandom(config.seed);
|
||||||
|
const numbers = Array.from({ length: config.count }, () => rng());
|
||||||
|
const round = n => Number(n.toFixed(6));
|
||||||
|
|
||||||
|
const mean = round(stats.mean(numbers));
|
||||||
|
const stddev = round(stats.standardDeviation(numbers));
|
||||||
|
const median = round(stats.median(numbers));
|
||||||
|
|
||||||
|
const tableString = table([
|
||||||
|
["Stat", "Value"],
|
||||||
|
["mean", String(mean)],
|
||||||
|
["stddev", String(stddev)],
|
||||||
|
["median", String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sanitizedHTML = DOMPurify.sanitize(`<pre class="stats">${tableString}</pre>`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: sanitizedHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
return { valid: false, errors: e?.message || String(e) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 30.390s
|
||||||
|
// Result: PASS
|
||||||
28
tests/4_hexchain_pipeline/outputs/x-ai_grok-4.js
Normal file
28
tests/4_hexchain_pipeline/outputs/x-ai_grok-4.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
async function hexchain(tomlStr) {
|
||||||
|
const {parse} = await import('https://esm.sh/smol-toml');
|
||||||
|
const config = parse(tomlStr);
|
||||||
|
const Ajv = (await import('https://esm.sh/ajv')).default;
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {type:'object', required:['seed','count','label'], properties:{seed:{type:'string'}, count:{type:'integer',minimum:1,maximum:10000}, label:{type:'string',minLength:1}}};
|
||||||
|
if (!ajv.validate(schema, config)) return {valid:false, errors: ajv.errorsText()};
|
||||||
|
const seedrandom = (await import('https://esm.sh/seedrandom')).default;
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const nums = Array.from({length: config.count}, () => rng());
|
||||||
|
const ss = await import('https://esm.sh/simple-statistics');
|
||||||
|
let mean = ss.mean(nums);
|
||||||
|
let stddev = ss.standardDeviation(nums);
|
||||||
|
let median = ss.median(nums);
|
||||||
|
mean = Math.round(mean * 1e6) / 1e6;
|
||||||
|
stddev = Math.round(stddev * 1e6) / 1e6;
|
||||||
|
median = Math.round(median * 1e6) / 1e6;
|
||||||
|
const textTable = (await import('https://esm.sh/text-table')).default;
|
||||||
|
const tableArr = [['Stat','Value'], ['mean', String(mean)], ['stddev', String(stddev)], ['median', String(median)]];
|
||||||
|
const tableStr = textTable(tableArr);
|
||||||
|
const DOMPurify = (await import('https://esm.sh/dompurify')).default;
|
||||||
|
const html = '<pre class="stats">' + tableStr + '</pre>';
|
||||||
|
const sanitized = DOMPurify.sanitize(html);
|
||||||
|
return {valid:true, label:config.label, stats:{mean, stddev, median}, table: sanitized, count:config.count};
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 130.290s
|
||||||
|
// Result: PASS
|
||||||
60
tests/4_hexchain_pipeline/outputs/z-ai_glm-4.7.js
Normal file
60
tests/4_hexchain_pipeline/outputs/z-ai_glm-4.7.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const hexchain = async (tomlStr) => {
|
||||||
|
const [
|
||||||
|
{ default: parseToml },
|
||||||
|
{ default: seedrandom },
|
||||||
|
ss,
|
||||||
|
{ default: Ajv },
|
||||||
|
{ default: textTable },
|
||||||
|
{ default: DOMPurify }
|
||||||
|
] = await Promise.all([
|
||||||
|
import('https://esm.sh/smol-toml'),
|
||||||
|
import('https://esm.sh/seedrandom'),
|
||||||
|
import('https://esm.sh/simple-statistics'),
|
||||||
|
import('https://esm.sh/ajv'),
|
||||||
|
import('https://esm.sh/text-table'),
|
||||||
|
import('https://esm.sh/dompurify')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parseToml(tomlStr);
|
||||||
|
const ajv = new Ajv();
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
required: ['seed', 'count', 'label'],
|
||||||
|
properties: {
|
||||||
|
seed: { type: 'string' },
|
||||||
|
count: { type: 'integer', minimum: 1, maximum: 10000 },
|
||||||
|
label: { type: 'string', minLength: 1 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = new seedrandom(config.seed);
|
||||||
|
const numbers = Array.from({ length: config.count }, rng);
|
||||||
|
|
||||||
|
const [mean, stddev, median] = [
|
||||||
|
ss.mean(numbers),
|
||||||
|
ss.standardDeviation(numbers),
|
||||||
|
ss.median(numbers)
|
||||||
|
].map(n => parseFloat(n.toFixed(6)));
|
||||||
|
|
||||||
|
const tableStr = textTable([
|
||||||
|
['Stat', 'Value'],
|
||||||
|
['mean', String(mean)],
|
||||||
|
['stddev', String(stddev)],
|
||||||
|
['median', String(median)]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const cleanHTML = DOMPurify.sanitize(`<pre class="stats">${tableStr}</pre>`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
label: config.label,
|
||||||
|
stats: { mean, stddev, median },
|
||||||
|
table: cleanHTML,
|
||||||
|
count: config.count
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 53.399s
|
||||||
|
// Result: FAIL
|
||||||
27
tests/4_hexchain_pipeline/outputs/z-ai_glm-5.js
Normal file
27
tests/4_hexchain_pipeline/outputs/z-ai_glm-5.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
async function hexchain(toml) {
|
||||||
|
const [{ parse }, { default: seedrandom }, ss, { default: Ajv }, { default: table }, { default: DOMPurify }] = await Promise.all([
|
||||||
|
import('https://esm.sh/smol-toml'),
|
||||||
|
import('https://esm.sh/seedrandom'),
|
||||||
|
import('https://esm.sh/simple-statistics'),
|
||||||
|
import('https://esm.sh/ajv'),
|
||||||
|
import('https://esm.sh/text-table'),
|
||||||
|
import('https://esm.sh/dompurify')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const config = parse(toml);
|
||||||
|
const schema = { type: 'object', required: ['seed', 'count', 'label'], properties: { seed: { type: 'string' }, count: { type: 'integer', minimum: 1, maximum: 10000 }, label: { type: 'string', minLength: 1 } } };
|
||||||
|
const ajv = new Ajv();
|
||||||
|
|
||||||
|
if (!ajv.validate(schema, config)) return { valid: false, errors: ajv.errorsText() };
|
||||||
|
|
||||||
|
const rng = seedrandom(config.seed);
|
||||||
|
const nums = Array.from({ length: config.count }, () => rng());
|
||||||
|
const r = n => Math.round(n * 1e6) / 1e6;
|
||||||
|
const mean = r(ss.mean(nums)), stddev = r(ss.standardDeviation(nums)), median = r(ss.median(nums));
|
||||||
|
|
||||||
|
const t = table([['Stat', 'Value'], ['mean', String(mean)], ['stddev', String(stddev)], ['median', String(median)]]);
|
||||||
|
return { valid: true, label: config.label, stats: { mean, stddev, median }, table: DOMPurify.sanitize(`<pre class="stats">${t}</pre>`), count: config.count };
|
||||||
|
}
|
||||||
|
export default hexchain;
|
||||||
|
// Generation time: 132.298s
|
||||||
|
// Result: PASS
|
||||||
Reference in New Issue
Block a user