Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-13 21:24:36 +00:00
parent 63fdb538ff
commit a38ae2d0c5
62 changed files with 532 additions and 1161 deletions

View File

@@ -1,26 +0,0 @@
async function findConvexHull(points) {
const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js').then(m => m.default);
if (points.length < 3) return points;
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (sorted.length < 3) return sorted;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const buildHull = pts => {
const hull = [];
for (const p of pts) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop();
}
hull.push(p);
}
hull.pop();
return hull;
};
return [...buildHull(sorted), ...buildHull(sorted.slice().reverse())];
}
export default findConvexHull;

View File

@@ -1,9 +1,9 @@
async function findConvexHull(points) {
const { sortBy, uniqWith } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js');
const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js').then(m => m.default);
if (points.length < 3) return points;
const sorted = sortBy(uniqWith(points, (a, b) => a.x === b.x && a.y === b.y), ['x', 'y']);
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (sorted.length < 3) return sorted;

View File

@@ -1,26 +0,0 @@
async function findConvexHull(points) {
const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js').then(m => m.default);
if (points.length < 3) return points;
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (sorted.length < 3) return sorted;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const buildHull = pts => {
const hull = [];
for (const p of pts) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop();
}
hull.push(p);
}
hull.pop();
return hull;
};
return [...buildHull(sorted), ...buildHull(sorted.slice().reverse())];
}
export default findConvexHull;

View File

@@ -1,29 +0,0 @@
async function findConvexHull(points) {
const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm');
if (points.length < 3) {
return [...points];
}
const crossProduct = (p1, p2, p3) =>
(p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
const sortedPoints = sortBy(points, ['x', 'y']);
const buildHull = (pts) =>
pts.reduce((hull, p) => {
while (hull.length >= 2 && crossProduct(hull[hull.length - 2], hull.at(-1), p) <= 0) {
hull.pop();
}
hull.push(p);
return hull;
}, []);
const lowerHull = buildHull(sortedPoints);
const upperHull = buildHull([...sortedPoints].reverse());
const combinedHull = [...lowerHull, ...upperHull];
return uniqWith(combinedHull, isEqual);
}
export default findConvexHull;

View File

@@ -0,0 +1,27 @@
async function findConvexHull(points) {
const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js');
const uniquePoints = uniqWith(points, isEqual);
if (uniquePoints.length < 3) {
return uniquePoints;
}
const sortedPoints = sortBy(uniquePoints, ['x', 'y']);
const crossProduct = (p1, p2, p3) =>
(p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
const buildHull = pts => pts.reduce((hull, p) => {
while (hull.length >= 2 && crossProduct(hull.at(-2), hull.at(-1), p) <= 0) {
hull.pop();
}
hull.push(p);
return hull;
}, []);
const lower = buildHull(sortedPoints);
const upper = buildHull([...sortedPoints].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
}
export default findConvexHull;

View File

@@ -1,15 +0,0 @@
let h
const findConvexHull=async v=>{
const {sortBy,uniqWith,isEqual}=await(h??=import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm'))
const s=uniqWith(sortBy(v,['x','y']),isEqual)
if(s.length<3)return s.slice()
const r=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x)
const l=[]
for(const p of s){while(l.length>1&&r(l.at(-2),l.at(-1),p)<=0)l.pop();l.push(p)}
const u=[]
for(let i=s.length;i--;){const p=s[i];while(u.length>1&&r(u.at(-2),u.at(-1),p)<=0)u.pop();u.push(p)}
l.pop()
u.pop()
return l.concat(u)
}
export default findConvexHull;

View File

@@ -0,0 +1,23 @@
let cache
const loader=()=>cache??=import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js')
export const findConvexHull=async pts=>{
const {sortBy:s,uniqWith:u,isEqual:e}=await loader()
const data=u(s(pts,[v=>v.x,v=>v.y]),e)
if(data.length<2)return data.slice()
const cross=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x)
const lower=[],upper=[]
for(const p of data){
while(lower.length>1&&cross(lower.at(-2),lower.at(-1),p)<=0)lower.pop()
lower.push(p)
}
for(let i=data.length;i--;){
const p=data[i]
while(upper.length>1&&cross(upper.at(-2),upper.at(-1),p)<=0)upper.pop()
upper.push(p)
}
lower.pop()
upper.pop()
return lower.concat(upper)
}
export default findConvexHull;

View File

@@ -1,23 +0,0 @@
async function findConvexHull(points) {
if (!Array.isArray(points) || points.length < 1) return [];
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.default.min.js');
const s = _.uniqBy(points, p => `${p.x},${p.y}`);
if (s.length < 2) return s.slice();
const pts = _.sortBy(s, ['x', 'y']);
const c = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const l = [];
for (let p of pts) {
for (; l.length > 1 && c(l[l.length - 2], l[l.length - 1], p) <= 0;) l.pop();
l.push(p);
}
const u = [];
for (let i = pts.length - 1; i >= 0; i--) {
const p = pts[i];
for (; u.length > 1 && c(u[u.length - 2], u[u.length - 1], p) <= 0;) u.pop();
u.push(p);
}
l.pop();
u.pop();
return l.concat(u);
}
export default findConvexHull;