npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

benchscript

v0.2.3

Published

**A console application based on NodeJs.**

Downloads

6

Readme

Benchmark for functions written on typescript

A console application based on NodeJs.

This is a minimal console application for benchmarking your functions on NodeJS application written in TypeScript or JS. Application calculates time to run a function, cpu usage, and ram usage.

Use this app along with NodeJS and TypeScript. NodeJs TypeScript

A basic Benchmark application needs just few files to run and test your code:

  • package.json - Points to the app's main file and lists its details and dependencies.
  • tsconfig.json - Has all configurations needed for TypeScript file to compile properly.

To Use

To install this package you need to run command bellow

npm i benchscript

Note: If you're using Linux Bash for Windows, see this guide or use node from the command prompt.

Using CLI

For using benchmark on your function you need to go through few steps:

  • Create a TypeScript file containing your test functions as below:
export const testFunctions = [
  {
    title: "SampleTitle1",
    fn: function YourFunction1() {
      //Does something
    },
  },
  {
    title: "SampleTitle2",
    fn: function YourFunction2() {
      //Does something
    },
  },
  {
    title: "SampleTitle3",
    fn: function YourFunction3() {
      //Does something
    },
  },
];
  • Or create a JavaScript file containing your test functions as below:
Object.defineProperty(exports, "__esModule", { value: true });
exports.testFunctions = [
  {
    title: "SampleTitle1",
    fn: function YourFunction1() {
      //Does something
    },
  },
  {
    title: "SampleTitle2",
    fn: function YourFunction3() {
      //Does something
    },
  },
  {
    title: "SampleTitle3",
    fn: function YourFunction3() {
      //Does something
    },
  },
];
  • Save your file and copy it`s path

  • Run bash command and put you file path into it

  • Give number of iterations(number of how many times each function needed to be called on each run)

  • Give number of runs(number of runs for calculating average results after dumping)

bench --path /YourTestFilePath --iterations "-number of iterations" --runs "-number of runs"
  • Get results:
┌───────────────┬───────────────────┬──────────┬───────────┬───────────────────────────────┬─────────────────┐
│     Title     │ Average Time (ms) │ CPU (%)  │ RAM (MB)  │ Average Infelicity Time (ms)  │ Difference (%)  │
├───────────────┼───────────────────┼──────────┼───────────┼───────────────────────────────┼─────────────────┤
│ SampleTitle1  │       xxxxx       │  xxxxx   │   xxxxx   │             xxxxx             │      Best       │
│ SampleTitle2  │       xxxxx       │  xxxxx   │   xxxxx   │             xxxxx             │ Slower by xxxxx │
│ SampleTitle3  │       xxxxx       │  xxxxx   │   xxxxx   │             xxxxx             │ Slower by xxxxx │
└───────────────┴───────────────────┴──────────┴───────────┴───────────────────────────────┴─────────────────┘

How to use. (Inside your application)