https://github.com/kwhitley/string-timer
Dead simple benchmark/elapsed timer, run purely from string outputs.
https://github.com/kwhitley/string-timer
Last synced: 3 months ago
JSON representation
Dead simple benchmark/elapsed timer, run purely from string outputs.
- Host: GitHub
- URL: https://github.com/kwhitley/string-timer
- Owner: kwhitley
- License: mit
- Created: 2016-08-24T16:18:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-07T06:18:56.000Z (about 9 years ago)
- Last Synced: 2025-07-21T09:39:40.719Z (5 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# string-timer
Dead simple benchmark/elapsed timer, run purely from string outputs.
### installation
```bash
npm install string-timer
```
### usage
```js
const StringTimer = import('string-timer');
let time = new StringTimer; // instantiation begins the timer
// do some stuff
console.log(`time elapsed: {time}`); // time elapsed: 1.5sec
// do some more stuff
console.log(`time elapsed: {time}`); // time elapsed: 256ms
// set a marker
console.log(`time elapsed: {time.set('foo')}`); // time elapsed: 2ms
// do some stuff
console.log(`time elapsed: {time}`); // time elapsed: 10ms
console.log(`time elapsed: {time}`); // time elapsed: 5ms
console.log(`time elapsed: {time}`); // time elapsed: 25ms
// calculate from marker
console.log(`time elapsed: {time.from('foo')}`); // time elapsed: 40ms
```
### notes
- instantiation initializes a timer
- accessing the timer object itself from a string triggers the calculation and string formatting