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

9
LINES

< > BotCompany Repo | #1028976 // formatElapsedTimeWithAppropriateUnit [seconds down to nanoseconds]

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

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

1  
sS formatElapsedTimeWithAppropriateUnit(double seconds) {
2  
  if (seconds >= 1) ret formatDouble(seconds, 3) + " s";
3  
  double ms = seconds*1000;
4  
  if (ms >= 1) ret formatDouble(ms, 3) + " ms";
5  
  double us = ms*1000;
6  
  if (us >= 1) ret formatDouble(us, 3) + " µs";
7  
  double ns = us*1000;
8  
  ret formatDouble(ns, 3) + " ns";
9  
}

Author comment

Began life as a copy of #1010912

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: #1028976
Snippet name: formatElapsedTimeWithAppropriateUnit [seconds down to nanoseconds]
Eternal ID of this version: #1028976/2
Text MD5: ad223405fa3f57f9071dc45a4052cd93
Transpilation MD5: 69fb0f3c8a570232b7bdd2fc22a04411
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-15 01:59:00
Source code size: 330 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 151 / 221
Version history: 1 change(s)
Referenced in: [show references]