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

13
LINES

< > BotCompany Repo | #1028993 // TimeCollector

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

Libraryless. Click here for Pure Java version (107L/1K).

sclass TimeCollector {
  long count, totalNanos;
  
  void addNanos(long nanos) {
    ++count;
    totalNanos += nanos;
  }
  
  toString {
    ret count == 0 ? "Empty time collector"
      : "Average time: " + formatElapsedTimeWithAppropriateUnit(nanosToSeconds(doubleRatio(totalNanos, count))) + " (n=" + count + ")";
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028993
Snippet name: TimeCollector
Eternal ID of this version: #1028993/3
Text MD5: 68a7c6f64cf68ec70e2b42c908f3c6f8
Transpilation MD5: e2f554e16c7ff621e6398c0755f8556f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-16 18:03:15
Source code size: 337 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 424
Version history: 2 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)