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.

sclass RunResultWithTimestamps<A> extends OKOrError<A> {
  settable Timestamp started;
  settable Timestamp ended;
  settable CharSequence printOutput;

  selfType run(IF0<A> f, bool printStackTrace default true) {
    ret setPrintOutput(hijackPrint_tee(r {
      started(tsNow());
      copyFrom(okOrError(f, printStackTrace));
      ended(tsNow());
    }));
  }
  
  bool hasRun() { ret ended != null; }
  
  // legacy
  OKOrError result() { this; }
  
  Duration duration() { ret ended.minusAsDuration(started); }
  
  S renderDuration() {
    ret formatElapsedTimeWithAppropriateUnit(nanosToSeconds(duration().toNanos()));
  }
}

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: 203 / 398
Version history: 16 change(s)
Referenced in: [show references]