https://github.com/codewell/time-it-js
Calculate the execution time of a function in JavaScript
https://github.com/codewell/time-it-js
Last synced: 30 days ago
JSON representation
Calculate the execution time of a function in JavaScript
- Host: GitHub
- URL: https://github.com/codewell/time-it-js
- Owner: codewell
- License: mit
- Created: 2020-04-16T20:12:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T16:41:35.000Z (over 3 years ago)
- Last Synced: 2023-03-02T23:06:08.291Z (over 3 years ago)
- Language: JavaScript
- Size: 868 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @codewell/time-it-js
Calculate the execution time of a function in JavaScript.
Works with both sync and async functions. Always returns a promise.
## Installation
```
npm install @codewell/time-it
```
## Basic Usage
```JavaScript
import timeIt from '@codewell/time-it';
// Write examples here
const slowMessage = (message) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(message);
}, 1000);
});
};
const message = await timeIt(slowMessage, "Description")("Hello, World!")
// Prints "Description: 1000ms" to the console
// and returns the message => "Hello, World!"
```
## Issues
Please help by posting issues here on github