mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for openai/gpt-5.3-codex
This commit is contained in:
@@ -1,4 +1,42 @@
|
||||
const loadPriorityQueue = (() => {
|
||||
let p;
|
||||
return () =>
|
||||
p ??= import("https://esm.sh/js-priority-queue").then(m => m.default || m);
|
||||
})();
|
||||
|
||||
async function findShortestPath(graph, start, end) {
|
||||
if (start === end) return 0;
|
||||
if (!graph || typeof graph !== "object") return Infinity;
|
||||
|
||||
const PriorityQueue = await loadPriorityQueue();
|
||||
const dist = { [start]: 0 };
|
||||
const seen = new Set();
|
||||
const q = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
|
||||
q.queue([start, 0]);
|
||||
|
||||
while (q.length) {
|
||||
const [node, d] = q.dequeue();
|
||||
if (seen.has(node)) continue;
|
||||
seen.add(node);
|
||||
if (node === end) return d;
|
||||
|
||||
const next = graph[node];
|
||||
if (!next || typeof next !== "object") continue;
|
||||
|
||||
for (const n in next) {
|
||||
const w = next[n];
|
||||
if (!Number.isFinite(w) || w < 0) continue;
|
||||
const nd = d + w;
|
||||
if (nd < (dist[n] ?? Infinity)) {
|
||||
dist[n] = nd;
|
||||
q.queue([n, nd]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 0.986s
|
||||
// Result: FAIL
|
||||
// Generation time: 15.189s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user