A budget that holds on a slower machine, kept as it is while the time stays well inside it.
(seconds, kept)
| 219 | |
| 220 | /** A budget that holds on a slower machine, kept as it is while the time stays well inside it. */ |
| 221 | function budgetFor(seconds, kept) { |
| 222 | const wanted = Math.max(BUDGET_FLOOR_SECONDS, Math.ceil(seconds * BUDGET_TIMES)); |
| 223 | if (kept && seconds * 1.5 <= kept && wanted * 2 >= kept) return kept; |
| 224 | return wanted; |
| 225 | } |
| 226 | |
| 227 | // --------------------------------------------------------------------------------------------- |
| 228 | // Answers |