Libraryless. Click here for Pure Java version (130L/1K).
sS renderElapsedSecondsPleasantly(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"; } sS renderElapsedSecondsPleasantly(Duration d) { ret d == null ?: renderElapsedSecondsPleasantly(nanosToSeconds(d.toNanos())); }
Began life as a copy of #1013915
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032607 |
Snippet name: | renderElapsedSecondsPleasantly - goes down to nanoseconds if value is very small |
Eternal ID of this version: | #1032607/6 |
Text MD5: | b6fcf06723a5e287ed9b8d0646345688 |
Transpilation MD5: | 1f1fb3671ff4c7baac7fe19db4561a71 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-01 19:09:39 |
Source code size: | 459 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 250 / 325 |
Version history: | 5 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1032608 - renderElapsedNanosPleasantly |