Hasty
.dev
New Benchmark
New Notebook
Shorts
Hasty
.dev
New Benchmark
New Notebook
Shorts
Shared Benchmark
Globals
const data = [ ...new Array(3500) ].map(Math.random)
Cases
Add case
0 ops/s
function bogoSort(items) { while (!isSorted(items)) shuffle(items); return items; } function isSorted(arr) { const length = arr.length; for (let i = 0; i < length - 1; i++) { if (arr[i] > arr[i + 1]) return false; } return true; } function shuffle(arr) { for (let i = arr.length - 1; i; i--) { const m = Math.floor(Math.random() * i); const n = arr[i - 1]; arr[i - 1] = arr[m]; arr[m] = n; } } bogoSort(data)
0 ops/s
function bucketSort(arr, bucketSize) { if (arr.length < 2) { return arr; } const buckets = createBuckets(arr, bucketSize); return sortBuckets(buckets); } function createBuckets(arr, bucketSize) { let min = arr[0]; let max = arr[0]; for (let i = 1; i < arr.length; i++) { if (arr[i] < min) { min = arr[i]; } else if (arr[i] > max) { max = arr[i]; } } const bucketCount = Math.floor((max - min) / bucketSize) + 1; const buckets = []; for (let i = 0; i < arr.length; i++) { const bucketIndex = Math.floor((arr[i] - min) / bucketSize); if (!buckets[bucketIndex]) buckets[bucketIndex] = []; buckets[bucketIndex].push(arr[i]); } return buckets; } function sortBuckets(buckets) { const sortedArr = []; for (let i = 0; i < buckets.length; i++) { if (buckets[i] != null) { insertionSort(buckets[i]); sortedArr.push(...buckets[i]); } } return sortedArr; } bucketSort(data)
Epochs:
Timeout:
Embed
Share
Options
Run
Hasty
.dev
Unleash the power of performance by comparing your code.
Performance. Unbound.
New Benchmark
New Notebook
Explore
Shorts
Blog
Popular
More
Donate
Wall of love
Uptime
Socialize
Telegram
Bluesky
Upvote Club
HASTY.dev
Explore HASTY, your go-to platform for reliable JS benchmark tests. Improve your JavaScript performance and coding efficiency today by optimizing it.
https://techhub.social/@Mobilpadde
https://techhub.social/@Mobilpadde/112172445238616181
https://techhub.social/@Mobilpadde/112172445238616181