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

autocannon-storage

v0.0.1

Published

A utility for storing and sorting autocannon results

Downloads

8

Readme

banner

Autocannon-storage

A utility module for storing autocannon results in s3 and sorting/retrieving them in useful manners.

Usage

Command-line

Usage: autocannon-storage {command} [opts]

A convenient command-line library for storing autocannon results in S3

Available commands:
  save
    Save autocannon results to s3
  load
    Load autocannon results from s3 and output them as ndjson

Available options:

  -i/--input FILE
        The path to some json results to save. Required when not piping into this tool.
  -o/--output DIRECTORY
        The path to some directory to save results in. Will save results in `${result.finish}.json`
  -c/--credentials FILE
        The path to some json file with S3 credentials
  -k/--accessKey S3_ACCESS_KEY
        Some S3 access key
  -K/--secretKey S3_SECRET_KEY
        Some S3 secret key
  -b/--bucket NAME
        The title of some S3 bucket
  -a/--amount AMOUNT
        The amount of results to load
  -t/--tag TAG
        A semver version tag to tag the results with if doing a save.
        An NPM version tag to filter results by if doing a load.
  -v/--version
        Print the version number.
  -h/--help
        Print this menu.

Example

saving

autocannon -d 30 -j localhost:3000 | autocannon-storage save -c ./s3Credentials.json -t `node -e "console.log(require('./package.json').version)"`

loading

autocannon-storage load -c ./s3Credentials.json -t ">=1.0.0" | autocannon-reporter

Programmatically

'use strict'

const storage = require('autocannon-storage')
const abstractBlobStore = require('abstract-blob-store')
const autocannonResults = require('./SOME_AUTOCANNON_RESULTS')

storage.createStore(abstractBlobStore, function (err, store) {
  store.save(autocannonResults, function (error) {
    // ...
  })
  store.load({}, function (error, results) {
    // ...
  })
})

API

createStore(store, callback)

Creates an autocannon-storage store that wraps around some library that the implements abstract-blob-store api

  • store: An object that implements the abstract-blob-store API
  • callback(err, store): the callback that is called when the store is instantiated. This takes an error and store as parameters. The store implements the store api described below.

Store API

An autocannon store object is passed in the callback of the createStore, and it wraps an abstract-blob-store library. It has the following methods.

store.save(results, cb, metadata)

This takes autocannon results and saves it in the store. These results can also have an added tag attribute with semver tags for utilty filtering later.

The callback takes error and metadata parameters for utility purposes.

store.load(opts, cb)

This takes a set of options and loads results matching those params from the store.

The callback takes error and results parameters.

  • opts.amt: The amount of results to load
  • opts.sort: a sorting function which is used to sort results before returning. defaults to sorting by most recent finish time in the autocannon results

store.filter(opts, cb)

This takes a set of options and filters results to matching those params from the store.

The callback takes error and results parameters.

  • opts.filter: A filter function which should return true if some metadata passed to it should be included in the downloaded results. Can be used to filter by tags.
  • opts.amt: The amount of results to load
  • opts.sort: a sorting function which is used to sort results before returning. defaults to sorting by most recent finish time in the autocannon results

Utility

createS3Store(credentials, bucket)

A wrapper around s3-blob-store that creates and returns that store when passed valid credentials and a bucket name

Valid credentials have accessKey and secretKey attributes. Used by the command line functionality.

Acknowlegements

Sponsored by nearform

License

MIT.