0.0.2 • Published 2 years ago

performancer v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Performancer is a function execution time checker

You can easily check how much time does a function need to be executed in a following way:


E.g: to check the Synchronous code:

// Import the module for synchronous code check!
const { checkTime } = require("performancer");

// Create a function
const inArray = () => {
  const array = Array.from(Array(100000000).keys());
  return array.includes(91204234);
}

// Time checker functions have 4 options:
// 1. fraction: default = 2, fraction digis number;
// 2. format: default = 'millis' | 'seconds' | 'minutes' in which type you want to receive execution time result;
// 3. returnResponse: default = false, if you want to receive the function execution response back make the value `true`;
// 4. withoutUnit: default = false, if you want to receive a float result for the function execution time make it `true`;
// NOTE: you are putting the reference to your function and do not call it while setting the parameter to the function!
checkTime(inArray, { fraction: 3, format: "millis", returnResponse: false, withoutUnit: true })

const { checkTimeAsync } = require("performancer");
// If you have an async request and want to know how long it takes for javascript to 
// Create an async function
const request = async() => await fetch(
  'http://localhost:8080/api/fake-data'
).then(async (res) => await res.json());


checkTimeAsync(inArray, { fraction: 2, format: "seconds", returnResponse: true, withoutUnit: false })