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).

sS formatElapsedTimeWithAppropriateUnit(double seconds) {
  if (seconds >= 1) ret formatDouble(seconds, 3) + " s";
  double ms = seconds*1000;
  if (ms >= 1) ret formatDouble(ms, 3) + " ms";
  double us = ms*1000;
  if (us >= 1) ret formatDouble(us, 3) + " µs";
  double ns = us*1000;
  ret formatDouble(ns, 3) + " ns";
}

Author comment

Began life as a copy of #1010912

download  show line numbers  debug dex   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, 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: 11 / 25
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1028976 & http://1028976.tinybrain.de