Libraryless. Click here for Pure Java version (9347L/52K).
1 | srecord noeq StepperWithStats(Steppable steppable) > MetaWithChangeListeners is Steppable { |
2 | settableWithVar new TimestampRange timeRange; |
3 | settableWithVar long stepCount; |
4 | settableWithVar bool done; |
5 | |
6 | public bool step() { |
7 | if (done) false; |
8 | if (steppable == null) false; |
9 | |
10 | ping(); |
11 | if (timeRange.start() == null) timeRange.startTime(tsNow()); |
12 | stepCount(stepCount+1); |
13 | if (steppable.step()) true; |
14 | |
15 | // steppable ended |
16 | timeRange.endTime(tsNow()); |
17 | done(true); |
18 | false; |
19 | } |
20 | |
21 | S renderStats() { |
22 | S s = nSteps(stepCount); |
23 | if (done) { |
24 | s += " (done"; |
25 | if (timeRange.complete()) |
26 | s += " in " + formatSeconds(timeRange.duration(), 1) + "s"; |
27 | s += ")"; |
28 | } |
29 | ret s; |
30 | } |
31 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035117 |
Snippet name: | StepperWithStats |
Eternal ID of this version: | #1035117/5 |
Text MD5: | 2f0a0f768034b4f8bfa4e1dc9e068619 |
Transpilation MD5: | 8742a08b097dc89917551fc62981ad76 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-04-02 16:47:04 |
Source code size: | 774 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 150 / 251 |
Version history: | 4 change(s) |
Referenced in: | [show references] |