Installations
npm install atlas-pretty-hrtime
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
^10.1.0
Node Version
10.1.0
NPM Version
6.0.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
atlassubbed
Download Statistics
Total Downloads
1,089
Last Day
3
Last Week
4
Last Month
9
Last Year
187
GitHub Statistics
14 Commits
2 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.0
Package Id
atlas-pretty-hrtime@1.0.0
Unpacked Size
7.21 kB
Size
3.04 kB
File Count
7
NPM Version
6.0.1
Node Version
10.1.0
Total Downloads
Cumulative downloads
Total Downloads
1,089
Last day
0%
3
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
12.5%
9
Compared to previous month
Last year
-34.8%
187
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
atlas-pretty-hrtime
Converts a time in nanoseconds to a pretty string in the most convenient units.
install
npm install --save atlas-pretty-hrtime
why
Printing times is annoying, so this is me thinking about it once and hopefully never again. If you are doing performance testing, you will encounter time diffs between different points in your code. With this module, you don't need to worry about how to print those times in various units with varying precision -- it's done automatically for you.
examples
The exported function takes a time
in nanoseconds, an optional precision integer and returns a string. The default precision is 3
decimal places, and the maximum unit is hours.
1const pretty = require("atlas-pretty-time"); 2// all times in nanoseconds 3const times = [ 4 // output units: 5 0, // ns 6 123, // ns 7 1234, // us 8 12345, // us 9 123456, // us 10 1234567, // ms 11 12345678, // ms 12 123456789, // ms 13 1234567890, // sec 14 12345678901, // sec 15 123456789012, // min 16 1234567890123, // min 17 12345678901234 // hr 18] 19times.forEach(time => { 20 // round to 1 decimal place 21 const prettyTime = pretty(time, 1); 22 console.log(prettyTime) 23}); 24// 0.0ns 25// 123.0ns 26// 1.2us 27// 12.3us 28// 123.5us 29// 1.2ms 30// 12.3ms 31// 123.5ms 32// 1.2sec 33// 12.3sec 34// 2.1min 35// 20.6min 36// 3.4hr
caveats
units
Only accepts times in nanoseconds, because supporting multiple input units is outside the scope of this package. This package is primarily for printing time diffs, which should not be in milliseconds or seconds if you're using high resolution time. See atlas-hrtime.
fractional minutes and hours
For simplicity, this module does not decompose fractional minutes into "minutes and seconds" (and similarly with hours). This doesn't bother me much, so I'm unlikely to implement something like:
1console.log(pretty(123456789012, 1)) 2// 2min 3sec
specifying return units
At the moment, this is not possible, but I may implement it in the future if I need finer-grained control on the output units:
1console.log(pretty(123456789012, 1, "sec")) 2// 123.5sec
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 3 are checked with a SAST tool
Score
2.9
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More