({ max = 100000 } = {})
| 29 | }; |
| 30 | |
| 31 | export const createIdPool = async ({ max = 100000 } = {}) => { |
| 32 | const set = new Set(); |
| 33 | |
| 34 | for (let i = 0; i < max; i++) { |
| 35 | set.add(createId()); |
| 36 | if (i % 10000 === 0) console.log(`${Math.floor((i / max) * 100)}%`); |
| 37 | if (set.size < i) { |
| 38 | info(`Collision at: ${i}`); |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | info("No collisions detected"); |
| 43 | |
| 44 | const ids = [...set]; |
| 45 | const numbers = ids.map((x) => idToBigInt(x.substring(1))); |
| 46 | const histogram = buildHistogram(numbers); |
| 47 | return { ids, numbers, histogram }; |
| 48 | }; |
no test coverage detected
searching dependent graphs…