Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1034722 // RunResultWithTimestamps

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (10834L) is out of date.

1  
sclass RunResultWithTimestamps<A> extends OKOrError<A> {
2  
  settable Timestamp started;
3  
  settable Timestamp ended;
4  
  settable CharSequence printOutput;
5  
6  
  selfType run(IF0<A> f, bool printStackTrace default true) {
7  
    ret setPrintOutput(hijackPrint_tee(r {
8  
      started(tsNow());
9  
      copyFrom(okOrError(f, printStackTrace));
10  
      ended(tsNow());
11  
    }));
12  
  }
13  
  
14  
  bool hasRun() { ret ended != null; }
15  
  
16  
  // legacy
17  
  OKOrError result() { this; }
18  
  
19  
  Duration duration() { ret ended.minusAsDuration(started); }
20  
  
21  
  S renderDuration() {
22  
    ret formatElapsedTimeWithAppropriateUnit(nanosToSeconds(duration().toNanos()));
23  
  }
24  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034722
Snippet name: RunResultWithTimestamps
Eternal ID of this version: #1034722/17
Text MD5: ea4c57a8484e792b1d13566d3bd2ac09
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-26 17:21:01
Source code size: 655 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 400
Version history: 16 change(s)
Referenced in: [show references]