* Compute how often to yield in a CPU-bound loop over `batchSize` * items: target ~20 yields per flush, clamped to a per-buffer band. * * The band lets each buffer reflect per-item cost: * - cheap loops (regex, shallow checks): min=1000, max=5000 → coarse * - heavy loops (JSON.parse +
(
batchSize: number,
opts: { min?: number; max?: number; targetYieldsPerFlush?: number } = {}
)
| 152 | * @param opts.targetYieldsPerFlush default 20 |
| 153 | */ |
| 154 | protected getYieldInterval( |
| 155 | batchSize: number, |
| 156 | opts: { min?: number; max?: number; targetYieldsPerFlush?: number } = {} |
| 157 | ): number { |
| 158 | const target = opts.targetYieldsPerFlush ?? 20; |
| 159 | const min = opts.min ?? 100; |
| 160 | const max = opts.max ?? 5000; |
| 161 | return Math.max(min, Math.min(max, Math.ceil(batchSize / target))); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Wrap an array of already-serialized JSONEachRow lines into an |
no outgoing calls
no test coverage detected