Skip to content

This is an npm package that compares 2 algorithms and returns the faster one

License

Notifications You must be signed in to change notification settings

Anirudh-sk/aet-npm-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AET (Algo Execution Timer)

🧑‍💻🕸️ Simple, fun npm package for Node.js & The Browser 🕸️🧑‍💻

NPM Version Node Version Jest is released under the MIT license.

Getting Started

Install using npm npm:

npm install aet-time

When should you use aet-time?

  • You have multiple algorithms in your code
  • You need to find the faster algorithm
  • Don't have the time to check the complexity
  • Find the faster code by using this package

Usage

Let's get started by writing a test for a hypothetical function that runs a loop. First, create a script.js file:

function fun1() {
    for (let index = 0; index < 100; index++){}
}

Now let's add another function to compare with the previous one in the same script.js file:

function fun2() {
    for (let index = 0; index < 100000; index++){}
}

Now lets import the package into the file to find which function is faster:

const aet = require('aet')

console.log(aet(fun1, fun2));

Your final code should look something like this:

const aet = require('aet')

function fun1() {
    for (let index = 0; index < 100000; index++){}
}
function fun2() {
    for (let index = 0; index < 1000000000; index++){}
}

console.log(aet(fun1, fun2));

Replace the dummy functions fun1 and fun2 with the algorithms you made and want to compare.

If the Algo given in the first parameter is faster it returns

-1

If the Algo given in the second parameter is faster it returns

1

If both take the same time to execute it returns

0

Contributing

Feel free to contribute to this project by opening issues and pull requests

Licence

This is an MIT licenced Project

About

This is an npm package that compares 2 algorithms and returns the faster one

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published