Skip to content

A NodeJS module that let's you take time on how long it takes to execute code in your project.

License

Notifications You must be signed in to change notification settings

luxwarp/codetimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Style Guide

CodeTimer

Intro

A NodeJS module that let's you take time on how long it takes to execute code in your project.

Check wiki for change log and more information here

Install

npm install codetimer --save-dev

Usage

Example code on how to run CodeTimer in your project.

const CodeTimer = require('codetimer')                      // import CodeTimer module.

const ct = new CodeTimer()                                  // Create new object from class.

ct.start()                                                  // Start the timer.

let result = 0

for (let i = 0; i < 1000000000; i++) {                      // Do some calculations.
  result++
}

ct.stop()                                                   // Stop the timer.

console.log('Result counter: ', result)                     // Print out the calculation.
console.log('Milliseconds: ', ct.getTime())                 // Print out the result. Result is in milliseconds by default.
console.log('Seconds: ', (ct.getTime() / 1000))             // Convert result to seconds. eg 0.834.

Result

Result of above code should look something like this.

Result counter:  1000000000
Milliseconds:  965
Seconds:  0.965

Testing

If you want to try some functions before using this module in your applications you can use the test.js file located in the root folder of this module and then run the file in your terminal with the command node ./test.js

License

ISC - © Copyright Mikael Carlsson

Note

Feel free to contribute the way you want.

About

A NodeJS module that let's you take time on how long it takes to execute code in your project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published