How to install
Most likely you will need this for local development only.
npm i -D @choksheak/timecli
Why do you need this?
I searched around (Dec 2020) and was unable to find any npm package that serves the same purpose. The closest match is gnomon, but the output is too heavy and it loses all console colors from the original output.
Some reasons why you want to install this package:
- Cross-platform portability - no need to worry about using platform-specific timer executables.
- Tiny in size - There are a few minimally-needed dependencies, but they are also tiny.
- Fast - takes 0.1 seconds or less to run.
- Simple - Outputs a one-liner at the end of the run, showing the time clearly.
- Convenient - Able to run any command from your PATH environment variable or in your local
- Non-intrusive - Just prepend any command with
timecliin your package.json to time the task everytime you run it!
- Fun! - console output is colored!
> npx timecli [timecli] Usage: npx timecli [command] <arguments> ...
> npx timecli node test.js [test.js] Test script: Yellow Cyan Green Red [timecli] Took 0.082s. [Exit code = 0]
> npx timecli sleep 10 [timecli] Took 10.688s. [Exit code = 0]
Over one minute
> npx timecli sleep 70 [timecli] Took 1m 12s (72.517s). [Exit code = 0]
If you want a native CLI tool that does pretty much the same thing, you can download timeit from https://github.com/choksheak/timeit which is written in Golang.
Hope you have fun using this script! 😄