Hasty
.dev
Performance. Unbound.
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 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)
0 ops/s
const MIN_MERGE = 32; function timSort(arr, n) { let minRun = minRunLength(MIN_MERGE); for (let i = 0; i < n; i += minRun) { insertionSort(arr, i, Math.min(i + MIN_MERGE - 1, n - 1)); } for (let size = minRun; size < n; size = 2 * size) { for (let left = 0; left < n; left += 2 * size) { let mid = left + size - 1; let right = Math.min(left + 2 * size - 1, n - 1); if (mid < right) merge(arr, left, mid, right); } } } function minRunLength(n) { let r = 0; while (n >= MIN_MERGE) { r |= n & 1; n >>= 1; } return n + r; } function insertionSort(arr, left, right) { for (let i = left + 1; i <= right; i++) { let temp = arr[i]; let j = i - 1; while (j >= left && arr[j] > temp) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = temp; } } function merge(arr, l, m, r) { let len1 = m - l + 1; let len2 = r - m; let left = new Array(len1); let right = new Array(len2); for (let x = 0; x < len1; x++) left[x] = arr[l + x]; for (let x = 0; x < len2; x++) right[x] = arr[m + 1 + x]; let i = 0; let j = 0; let k = l; while (i < len1 && j < len2) { if (left[i] <= right[j]) { arr[k] = left[i]; i++; } else { arr[k] = right[j]; j++; } k++; } while (i < len1) { arr[k] = left[i]; k++; i++; } while (j < len2) { arr[k] = right[j]; k++; j++; } } timSort(data, data.length);
Epochs:
Timeout:
Embed
Share
Options
Run
Shorts
Notebook Demo
Blog
Donate
Wall of love 😻
Popular
Telegram
Uptime
Bluesky
New Benchmark
New Notebook
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