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

juve

v0.1.3

Published

Assert performance metrics using phantomas

Downloads

6

Readme

juve

Build Status

Assert performance metrics using phantomas

A Node.js module that uses Phantomas to run performance tests against a given URL. It features the ability perform multiple trials against the same URL and make assertions against the combined average metrics.

Overview

To get started, require the juve module.

var juve = require('juve');

This returns a function which accepts a configuration object and a callback with the following structure.

juve({
  <options>
}, function (<results>) {
  ...
});

Options

options.trials

Type: Number Default value: 3

The number of times each URL will be sampled.

options.olympic

Type: Boolean Default value: false

Indicates whether or not to use olympic-style scoring. This will drop the largest and smallest values for each metric before averaging the trials. Only available when the number of trials is greater than three (3).

options.url

Type: String Default value: /

The URL to sample. This is combined with the baseUrl option to determine the full URL that will be sampled.

Assertions

The other keys of the options object can be taken directly from the phantomas documentation. The values indicate a maximum acceptable value. If multiple trials are used, the results will be averaged and compared to the asserted value.

Callback

The second argument to the juve() function is a callback that gets called once all the trials have completed and the combined results are gathered.

The argument is an object with three array properties:

  • pass: passing assertions
  • fail: failed assertions
  • trials: all asserted metric for each trial.

The items in the pass and fail lists look like:

{
  name: "some metric",
  expected: <the asserted value>,
  actual: <the actual combined average>
}

The items in the trials list is the raw results from the underlying adapter (i.e. Phantomas).

Promise

As an alternative to passing a callback, the juve function returns a promise that will pass the results object when resolved.

juve('http://some.site.com', {
  requests: 1
}).then(function (results) {
  // do some things with the results.
});

Usage Examples

Default Options

In this example, the default options are used to sample a single page from a target site. This asserts that the page does not make any extra requests.

var juve = require('juve');

juve('http://some.site.com', {
  requests: 1
}, function (results) {
  // do some things with the results.
});

Custom Options

In this example, some task options are overridden within the target. This can tighen or relax some options on a per-page basis.

var juve = require('juve');

juve('http://some.site.com', {
  requests: 1,
  timeToFirstByte: 200
}, function (results) {
  // do stuff with the results and stuff.
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

Release History

v0.1.3

  • The juve function accepts the url as the first parameter.
  • The juve function returns a promise in addition to accepting a callback.
  • The juve function assumes all properties of the second parameter are assertions. The "options" property is reserved for specifying configuration options.
  • Added travis-ci support.
  • Added integration tests.

v0.1.2

  • Includes trials in the results.
  • Better test coverage.

v0.1.0

  • Basic functionality

(working towards v0.2.0)