Git Product home page Git Product logo

perfbudget's Introduction

perfbudget

Build Status Code Climate Dependency Status

Performance budgeting

perfbudget is a stand-alone version of Tim Kadlec's (@tkadlec) grunt-perfbudget plugin. It is a node package for enforcing a performance budget. It uses webpagetest.org and the WebPagetest API Wrapper for NodeJS created by Marcel Duran.

perfbudget uses either a public or private instance of WebPagetest to perform tests on a specified URL. It compares test results to budgets you specify. If the budget is met, the tasks successfully completes. If the page exceeds your performance budgets, the task fails and informs you why.

Installation

# CLI
$ npm install -g perfbudget

# Node Module
$ npm install perfbudget

Usage

CLI

# using www.webpagetest.org
$ perfbudget --url http://www.bbc.co.uk --key [api_key]

# using private instance
$ perfbudget --url http://www.bbc.co.uk --instance [instance_url] --key [api_key] --location [location]

# setting budgets
$ perfbudget --url http://www.bbc.co.uk --key [api_key] --SpeedIndex 2000 --render 400

Flags

Config:

  • --url - URL you want WPT to run against | default : ""
  • --key - API key for WPT instance | default : ""
  • --instance - WPT instance to use | default : www.webpagetest.org
  • --location - WPT location to use | default : Dulles:Chrome

Budget:

  • --visualComplete | default : ""
  • --render | default : "1000"
  • --loadTime | default : ""
  • --docTime | default : ""
  • --fullyLoaded | default : ""
  • --bytesIn | default : ""
  • --bytesInDoc | default : ""
  • --requests | default : ""
  • --requestsDoc | default : ""
  • --SpeedIndex | default : "1000"

Node module

var perfbudget = require('perfbudget');

perfbudget.runTest(options, function(err, result) {
  if (err) {
    return console.log(err);
  }

  if (!result.pass) {
    console.log(
      '\n-----------------------------------------------' +
      '\nTest for ' + result.options.url + ' \t ' + colors.red('[FAILED]') +
      '\n-----------------------------------------------\n'
    );
    console.log(result.msg);
    console.log('Summary: ' + result.summary);
  } else {
    console.log(
      '\n-----------------------------------------------' +
      '\nTest for ' + result.options.url + ' \t ' + colors.green('[PASSED]') +
      '\n-----------------------------------------------\n'
    );
    console.log(result.msg);
    console.log('Summary: ' + result.summary);
  }
});

TODO

  • Remove the need for a --url flag. Instead just assume that whatever follows perfbudget is the URL.

NOTE

This is still a work in progress and things are likely to change with each release. As it stands this package works directly in CLI. I'll be working to make it easier to integrate with a Node project.

perfbudget's People

Contributors

stefanjudis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

perfbudget's Issues

Expose CLI tool and Node module

Hey hey,

nice job here!

What I'm thinking of is to write the modules the way that it can be required in other node modules but also be spawn from over the CLI.

For that only some restructuring might be needed to seperated CLI parsing and the actual perfbudget module. :)

If you like it please let me know. :) I think I've got some time to propose a PR.

Thanks.

Integrate testing into the module

Moving this into it's own issue from #2 so it's easier to keep tabs on what needs doing in regards to tests.

  • Integrate Travis.ci
  • Integrate CodeClimate
  • Write lib/normalizeCli.js tests
  • Write perfbudget.js tests.

Make wptInstance configurable

I'd like to use my own WPT instance.

For that I think webpagetest.org can be the default value but should be overwritable. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.