mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Docs: Update benchmark for google/gemini-3-flash-preview
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const hashPassword = async (password, salt) => {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.1.7/+esm');
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const derivedKey = await scrypt(
|
||||
encoder.encode(password),
|
||||
encoder.encode(salt),
|
||||
1024,
|
||||
8,
|
||||
1,
|
||||
32
|
||||
);
|
||||
|
||||
return Array.from(derivedKey, byte => byte.toString(16).padStart(2, '0')).join('');
|
||||
};
|
||||
export default hashPassword;
|
||||
// Generation time: 9.228s
|
||||
// Result: FAIL
|
||||
17
tests/11_geospatial/outputs/google_gemini-3-flash-preview.js
Normal file
17
tests/11_geospatial/outputs/google_gemini-3-flash-preview.js
Normal file
@@ -0,0 +1,17 @@
|
||||
export async function analyzeGPS(readings, boundary) {
|
||||
const T = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
|
||||
const pts = readings
|
||||
.filter(({ loc }) => T.booleanPointInPolygon(loc, boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc);
|
||||
|
||||
if (pts.length < 2) return 0;
|
||||
|
||||
const len = T.length(T.lineString(pts), { units: 'kilometers' });
|
||||
|
||||
return Math.round(len * 100) / 100;
|
||||
}
|
||||
export default analyzeGPS;
|
||||
// Generation time: 9.884s
|
||||
// Result: PASS
|
||||
28
tests/1_dijkstra/outputs/google_gemini-3-flash-preview.js
Normal file
28
tests/1_dijkstra/outputs/google_gemini-3-flash-preview.js
Normal file
@@ -0,0 +1,28 @@
|
||||
export const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||
|
||||
const dists = { [start]: 0 };
|
||||
const pq = new PQ({ comparator: (a, b) => a.w - b.w });
|
||||
|
||||
pq.queue({ n: start, w: 0 });
|
||||
|
||||
while (pq.length) {
|
||||
const { n, w } = pq.dequeue();
|
||||
|
||||
if (n === end) return w;
|
||||
if (w > (dists[n] ?? Infinity)) continue;
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[n] ?? {})) {
|
||||
const total = w + weight;
|
||||
if (total < (dists[neighbor] ?? Infinity)) {
|
||||
dists[neighbor] = total;
|
||||
pq.queue({ n: neighbor, w: total });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
// Generation time: 12.594s
|
||||
// Result: PASS
|
||||
27
tests/2_convex_hull/outputs/google_gemini-3-flash-preview.js
Normal file
27
tests/2_convex_hull/outputs/google_gemini-3-flash-preview.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export const findConvexHull = async (points) => {
|
||||
const _ = (await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm')).default;
|
||||
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
|
||||
if (sorted.length < 3) return sorted;
|
||||
|
||||
const crossProduct = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
|
||||
const buildChain = (arr) => {
|
||||
const chain = [];
|
||||
for (const p of arr) {
|
||||
while (chain.length >= 2 && crossProduct(chain[chain.length - 2], chain[chain.length - 1], p) <= 0) {
|
||||
chain.pop();
|
||||
}
|
||||
chain.push(p);
|
||||
}
|
||||
return chain;
|
||||
};
|
||||
|
||||
const lower = buildChain(sorted);
|
||||
const upper = buildChain([...sorted].reverse());
|
||||
|
||||
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
// Generation time: 12.985s
|
||||
// Result: PASS
|
||||
16
tests/3_lis/outputs/google_gemini-3-flash-preview.js
Normal file
16
tests/3_lis/outputs/google_gemini-3-flash-preview.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array@3');
|
||||
const tails = [];
|
||||
|
||||
for (const x of nums) {
|
||||
const i = bisectLeft(tails, x);
|
||||
tails[i] = x;
|
||||
}
|
||||
|
||||
return tails.length;
|
||||
};
|
||||
|
||||
|
||||
export default findLISLength;
|
||||
// Generation time: 13.472s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,7 @@
|
||||
const renderTemplate = async (template, data) => {
|
||||
const { default: hb } = await import('https://esm.sh/handlebars');
|
||||
return hb.compile(template)(data);
|
||||
};
|
||||
export default renderTemplate;
|
||||
// Generation time: 14.517s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,11 @@
|
||||
const parseMarkdown = async (md) => {
|
||||
const [{ marked }, { default: sanitize }] = await Promise.all([
|
||||
import('https://esm.sh/marked'),
|
||||
import('https://esm.sh/dompurify')
|
||||
]);
|
||||
|
||||
return sanitize.sanitize(marked.parse(md));
|
||||
};
|
||||
export default parseMarkdown;
|
||||
// Generation time: 7.966s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,34 @@
|
||||
export const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
|
||||
const [{ parse }, { groupBy: group, sum: total }] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm')
|
||||
]);
|
||||
|
||||
const { data } = parse(csv, {
|
||||
header: true,
|
||||
skipEmptyLines: true
|
||||
});
|
||||
|
||||
const filtered = data.filter(r => r[filterColumn] == filterValue);
|
||||
const collections = group(filtered, groupBy);
|
||||
|
||||
return Object.entries(collections).map(([key, rows]) => {
|
||||
const values = rows.map(r => +r[aggregateColumn] || 0);
|
||||
const s = total(values);
|
||||
const n = values.length;
|
||||
|
||||
const calculations = {
|
||||
sum: s,
|
||||
avg: s / n,
|
||||
count: n
|
||||
};
|
||||
|
||||
return {
|
||||
[groupBy]: key,
|
||||
result: calculations[operation]
|
||||
};
|
||||
});
|
||||
};
|
||||
export default processCSV;
|
||||
// Generation time: 41.061s
|
||||
// Result: FAIL
|
||||
56
tests/7_scheduler/outputs/google_gemini-3-flash-preview.js
Normal file
56
tests/7_scheduler/outputs/google_gemini-3-flash-preview.js
Normal file
@@ -0,0 +1,56 @@
|
||||
export async function findAvailableSlots(cal1, cal2, { durationMinutes, searchRange, workHours }) {
|
||||
const dayjs = (await import('https://cdn.skypack.dev/dayjs')).default;
|
||||
const utc = (await import('https://cdn.skypack.dev/dayjs/plugin/utc')).default;
|
||||
dayjs.extend(utc);
|
||||
|
||||
const u = (v) => dayjs.utc(v);
|
||||
const sR = u(searchRange.start);
|
||||
const eR = u(searchRange.end);
|
||||
const [sh, sm] = workHours.start.split(':');
|
||||
const [eh, em] = workHours.end.split(':');
|
||||
|
||||
let blocked = [...cal1, ...cal2].map((b) => ({
|
||||
s: u(b.start),
|
||||
e: u(b.end)
|
||||
}));
|
||||
|
||||
for (let c = sR.startOf('d'); c <= eR; c = c.add(1, 'd')) {
|
||||
blocked.push(
|
||||
{ s: c, e: c.set('h', sh).set('m', sm) },
|
||||
{ s: c.set('h', eh).set('m', em), e: c.add(1, 'd') }
|
||||
);
|
||||
}
|
||||
|
||||
const merged = blocked
|
||||
.map((b) => ({
|
||||
s: b.s < sR ? sR : b.s,
|
||||
e: b.e > eR ? eR : b.e
|
||||
}))
|
||||
.filter((b) => b.s < b.e)
|
||||
.sort((a, b) => a.s - b.s)
|
||||
.reduce((acc, b) => {
|
||||
const p = acc[acc.length - 1];
|
||||
p && b.s <= p.e ? (p.e = b.e > p.e ? b.e : p.e) : acc.push(b);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const avail = [];
|
||||
let cursor = sR;
|
||||
|
||||
[...merged, { s: eR, e: eR }].forEach((b) => {
|
||||
while (cursor.add(durationMinutes, 'm') <= b.s) {
|
||||
const next = cursor.add(durationMinutes, 'm');
|
||||
avail.push({
|
||||
start: cursor.toISOString(),
|
||||
end: next.toISOString()
|
||||
});
|
||||
cursor = next;
|
||||
}
|
||||
if (b.e > cursor) cursor = b.e;
|
||||
});
|
||||
|
||||
return avail;
|
||||
}
|
||||
export default findAvailableSlots;
|
||||
// Generation time: 35.904s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,16 @@
|
||||
export const validateJSON = async (data, schema) => {
|
||||
const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/+esm');
|
||||
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||
const validate = ajv.compile(schema);
|
||||
const isValid = validate(data);
|
||||
|
||||
return {
|
||||
valid: isValid,
|
||||
errors: isValid ? [] : validate.errors.map(({ instancePath, message }) =>
|
||||
`${instancePath || 'root'} ${message}`.trim()
|
||||
)
|
||||
};
|
||||
};
|
||||
export default validateJSON;
|
||||
// Generation time: 6.123s
|
||||
// Result: PASS
|
||||
@@ -0,0 +1,33 @@
|
||||
export async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) {
|
||||
const d3 = await import("https://cdn.skypack.dev/d3@7");
|
||||
let data = [];
|
||||
let ema = null;
|
||||
|
||||
for await (const { timestamp, value } of asyncIterable) {
|
||||
ema = (ema === null) ? value : alpha * value + (1 - alpha) * ema;
|
||||
data.push({ timestamp, value, ema });
|
||||
if (data.length > maxPoints) data.shift();
|
||||
}
|
||||
|
||||
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(yDomain)
|
||||
.range([height, 0]);
|
||||
|
||||
const lineGenerator = d3.line()
|
||||
.x(d => x(d.timestamp))
|
||||
.y(d => y(d.ema));
|
||||
|
||||
return {
|
||||
data,
|
||||
path: lineGenerator(data)
|
||||
};
|
||||
}
|
||||
export default createStreamVisualizer;
|
||||
// Generation time: 11.081s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user