Libraryless. Click here for Pure Java version (4910L/28K).
svoid runProbabilisticForNSeconds(double seconds, IProbabilistic p) { if (p == null) ret; p.run(); runProbabilisticForNSeconds(seconds, p.scheduler()); } svoid runProbabilisticForNSeconds(double seconds, IProbabilisticScheduler ps) { if (ps == null) ret; Timeout timeout = new(seconds); long steps = 0; while (!timeout.reached()) { ++steps; if (!ps.step()) break; } print(nSteps(steps) + " in " + formatDouble(timeout.elapsedSeconds(), 1) + " s, reached probability " + ps.lastExecutedProbability()); }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033154 |
| Snippet name: | runProbabilisticForNSeconds |
| Eternal ID of this version: | #1033154/6 |
| Text MD5: | 00918c12b1c983d9f7ab1cea18882634 |
| Transpilation MD5: | b90cd802a1ed52b7d1ae55e03fe89978 |
| Author: | stefan |
| Category: | javax / probabilistic scheduling |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-15 19:55:24 |
| Source code size: | 555 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 372 / 492 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |