Compare generic helper styles for grouping typed records by a stable key.
type Product = {
sku: string
category: 'book' | 'tool' | 'game' | 'course'
price: number
stock: number
}
const products: Product[] = Array.from({ length: 1_500 }, (_, index) => ({
sku: 'sku-' + index,
category: (['book', 'tool', 'game', 'course'] as const)[index % 4],
price: 10 + (index % 97),
stock: index % 13,
}))
function bucketScore(item: Product): number {
return item.price * (item.stock + 1)
}Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| Object buckets | | ready |
| Map buckets | | ready |
| Generic group helper | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.