1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Print Milliseconds In Human-Readable Format as a Unix TIL

This commit is contained in:
jbranchaud
2023-08-14 14:57:56 -05:00
parent fb33d03d5a
commit fba4cb171f
2 changed files with 26 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1331 TILs and counting..._
_1332 TILs and counting..._
---
@@ -1317,6 +1317,7 @@ _1331 TILs and counting..._
- [Partial String Matching In Bash Scripts](unix/partial-string-matching-in-bash-scripts.md)
- [PID Of The Current Shell](unix/pid-of-the-current-shell.md)
- [Print A Range Of Lines For A File With Bat](unix/print-a-range-of-lines-for-a-file-with-bat.md)
- [Print Milliseconds In Human-Readable Format](unix/print-milliseconds-in-human-readable-format.md)
- [Print Out Files In Reverse](unix/print-out-files-in-reverse.md)
- [Print The Current Date In Human-Readable Format](unix/print-the-current-date-in-human-readable-format.md)
- [Provide A Fallback Value For Unset Parameter](unix/provide-a-fallback-value-for-unset-parameter.md)

View File

@@ -0,0 +1,24 @@
# Print Milliseconds In Human-Readable Format
I ran a command in a program. It doesn't really matter what command or program.
What does matter is that it took a long time and when it finished, it told me
how long it took, but in milliseconds.
```
835953ms
```
Typically, when I see a timing number like this, I open Alfred and do some
quick math (`N / 1000 / 60 / 60` or something like that).
There is an easier way, using the
[`pretty-ms-cli`](https://github.com/sindresorhus/pretty-ms-cli). This
purpose-built CLI can be run using something like
[`npx`](https://www.npmjs.com/package/npx). All I do is hand it the number of
milliseconds and it prints out how long that is in something that I can
understand.
```bash
npx pretty-ms-cli 835953
13m 56s
```