https://github.com/artskydj/ns-elapsed
:clock1: Simple, high resolution stopwatch for nodeJS. Ideal for benchmark times.
https://github.com/artskydj/ns-elapsed
Last synced: 3 months ago
JSON representation
:clock1: Simple, high resolution stopwatch for nodeJS. Ideal for benchmark times.
- Host: GitHub
- URL: https://github.com/artskydj/ns-elapsed
- Owner: ArtskydJ
- Created: 2014-06-12T16:20:14.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-03-11T03:04:25.000Z (about 10 years ago)
- Last Synced: 2024-04-24T16:10:13.550Z (almost 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ns-elapsed
==========
> Simple, high resolution stopwatch for nodeJS. Ideal for benchmark times.
[](https://travis-ci.org/ArtskydJ/ns-elapsed)
# examples
Asynchronous example
```js
var Elapsed() = require('ns-elapsed')
var e = new Elapsed()
e.set() // This is superfluous because 'set()' is automatically called when 'e' was constructed.
setTimeout(function() { // Asynchronous code here
console.log( e.get() )
}, 1000)
```
Synchronous example:
```js
var elapsed = require('ns-elapsed')()
// Synchronous code here
console.log( e.get() )
```
# api
```js
var Elapsed = require('ns-elapsed')
```
## `var e = new Elapsed()`
#### `e.set()`
Does not return anything. Automatically called upon construction.
#### `var sec = e.get()`
Returns the number of seconds elapsed. E.g. `13.947172826`, which is almost 14 seconds.
# install
Install with [NPM](http://nodejs.org)
npm install ns-elapsed
# license
[MIT](http://opensource.org/licenses/MIT)