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

buffalo-test

v2.0.0

Published

Performance test runner based on BuffaloBench and inspired by Mocha

Downloads

9

Readme

buffalo-test

Performance test runner based on BuffaloBench and inspired by Mocha

The purpose of this plugin is not only run benchmarks but to allow the developers to ensure that their application performance does not drops between commits or pull requests. By default it will fail if performance drops a certain percentage (2.5% by default).

To accomplish this task it will save a history based on the current git head id, package version or current date (git by default)

Table of Contents

Install

You can get this library as a Node.js module available through the npm registry:

// With npm
$ npm install buffalo-test --save
// With yarn
$ yarn add buffalo-test

Use

Create a folder for your tests in your project (default bench) and put your files in there.

let { compare, suite, benchmark } = require("buffalo-test");

compare("regex vs string", () => {
  benchmark("RegExp#test", () => /orl/.test("Hello World!"));
  benchmark("String#indexOf", () => "Hello World!".indexOf("o") > -1);
});

suite("suite only", () => {
  benchmark("suite only", () => /o/.test("Hello World!"));
});

To run the benchmarks just run from your terminal:

$ buffalo-test

It will show somthing like:


    Compare: regex vs string
        ✔ RegExp#test 6.104s (15,844,390 ops/sec)
        ✔ String#indexOf 6.075s (495,271,182 ops/sec)
        Compare: regex vs string completed in 12.179s, String#indexOf was fastest by 96.801%

    Suite: suite only
        ✔ suite only 5.871s (22,695,850 ops/sec)
        Suite: suite only passed in 5.871s

3 passing (18.05s)

Example

See the bench/index.js file.

Hooks

Buffalo-test provides the same hooks as mocha, before(), after(), beforeEach() and afterEach(). before() and after() run only once by suite. beforeEach() and afterEach() run before and after each benchmark respectively.

Also beforeCycle() and afterCycle() can be used to run code before and after the benchmark cycle.

Tests

Although buffalo-test is not a test-runner, you can run tests using expect.js or another library to check in each cycle that the benchmark is good.

Failed benchmarks, errors or test non cycle will be showed in the terminal as mocha does.

Exclusive tests and inclusive tests

As with mocha, you can run only benchmarks by appending .only() or skip them by appending .skip() to the desired suite.

Comand-line usage

Usage: buffalo-test [options] [dirs...]

Performance test runner based on BuffaloBench and inspired by Mocha

Options:
  -v, --version                   Output the version number
  -r, --reporter <spec>           Reporter to use (default: "spec")
  --enable-regressions            Allow benchmark regressions, if false benchmark will fail if there is a regression (default: false)
  --error-margin <margin>         Fail benchmark if performance drops this percentage amount (default: 2.5)
  --ignore-internals              Ignore internal modules when logging (default: true)
  --ignore-node-modules           Ignore node modules when logging (default: true)
  -R, --repository <repository>   Repository to use (default: "file")
  -t, --tag <tag>                 Tag to be used to identify this run (default: "git")
  -T, --tag-date-format <format>  Date format for the date tag (default: "YYYY-MM-DD")
  --file-name <file-name>         File to be used by the file repository (default: "bench/.buffalo-test.json")
  --require                       Files to require before tests
  -h, --help                      Display help for command

Available reporters:
 - spec

Available repositories:
 - file

Roadmap

  • Allow hook description
  • Allow to write pending tests
  • Add --bail option
  • Add --forbid-only option
  • Add --forbid-pending option
  • Implement option to load config from package.json or file
  • Add init command
  • Add create command

Contributing

  • Use prettify and eslint to lint your code.
  • Update the readme with an example if you add or change any functionality.

Legal

Author: Masquerade Circus. License Apache-2.0