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

@fadoli/node-fast-running-stats

v1.0.4

Published

library for computing running (or rolling) statistics for one set of values.

Downloads

9

Readme

node-fast-running-stats

This is a JavaScript/Node.js library for computing running (or rolling) statistics for one set of values.

Requires node 14 or more recent.

Can be found on :

Usage

const rollingArray = require("@fadoli/node-fast-running-stats");

// We will do stats on a maximum of 10 values (then last value override oldest one)
const myStats = new StatsArray(10);

myStats.append(0).getStats();
// { n: 1, min: 0, max: 0, sum: 0, mean: 0, variance: 0, standard_deviation: 0 }
myStats.append(1).getStats();
// { n: 2, min: 0, max: 1, sum: 1, mean: 0.5, variance: 0.25, standard_deviation: 0.5 }

Performance and Results

you can run this on your machine npm run bench

For each size we run the computation 100 times. We add twice the size one per one and compute the stats each time. This means for size 10 we will compute stats on 1,2,3,4,5,6,7,8,9,10 entries at first, then on 10 entries 10 times.

simple rollingArray implem, size = 10: 2.903ms
fastStats implem, size = 10: 3.149ms

simple rollingArray implem, size = 100: 22.486ms
fastStats implem, size = 100: 3.946ms

simple rollingArray implem, size = 1000: 1.318s
fastStats implem, size = 1000: 10.619ms

simple rollingArray implem, size = 2000: 4.882s
fastStats implem, size = 2000: 12.948ms

simple rollingArray implem, size = 3000: 11.237s
fastStats implem, size = 3000: 21.145ms

Here is the difference in output when both methods are compared :

{
  simple: {
    n: 3000,
    min: 0.00009501596644567734,
    max: 0.9999407084813299,
    sum: 1514.788964278203,
    mean: 0.504929654759401,
    variance: 0.08372214898153563,
    standard_deviation: 0.28934779933764077
  },
  fastStats: {
    n: 3000,
    min: 0.00009501596644567734,
    max: 0.9999407084813299,
    sum: 1514.7889642781986,
    mean: 0.5049296547593995,
    variance: 0.08372328892386063,
    standard_deviation: 0.28934976917886185
  }
}

This module's approach creates more errors related to the float precision errors (more computation are done and re-used and as such float precision errors are added as times goes on). The result is recomputed after a certain amount of times (2 times the size of the array, or at least 25k) to prevent it from causing big errors.

Coverage

File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------|---------|----------|---------|---------|------------------- All files | 98.91 | 96.29 | 100 | 98.91 | index.js | 98.91 | 96.29 | 100 | 98.91 | 119-120