Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-18 17:37:06 +00:00
parent 39d057f079
commit afcfd09537
84 changed files with 1086 additions and 1088 deletions

View File

@@ -1,18 +1,21 @@
async function findConvexHull(points) {
const {sortBy, uniqWith} = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js')
const ps = uniqWith(sortBy(points.map(({x, y}) => ({x: +x, y: +y})), ['x', 'y']), (a, b) => a.x === b.x && a.y === b.y)
if (ps.length < 2) return ps
const c = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const lower = []
for (const p of ps) {
while (lower.length > 1 && c(lower.at(-2), lower.at(-1), p) <= 0) lower.pop()
lower.push(p)
async function findConvexHull(points){
const m=await import('https://cdn.skypack.dev/lodash?min')
const _=m.default||m
const pts=_.sortBy(_.uniqWith(points,(a,b)=>a.x===b.x&&a.y===b.y),['x','y'])
if(pts.length<3)return pts.slice()
const h=[]
const c=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x)
for(const p of pts){
while(h.length>1&&c(h.at(-2),h.at(-1),p)<=0)h.pop()
h.push(p)
}
const upper = []
for (const p of [...ps].reverse()) {
while (upper.length > 1 && c(upper.at(-2), upper.at(-1), p) <= 0) upper.pop()
upper.push(p)
const t=h.length+1
for(let i=pts.length-2;i>=0;i--){
const p=pts[i]
while(h.length>=t&&c(h.at(-2),h.at(-1),p)<=0)h.pop()
h.push(p)
}
return lower.slice(0, -1).concat(upper.slice(0, -1))
h.pop()
return h
}
export default findConvexHull;