tkadlec / grunt-perfbudget

Grunt task for performance budgeting.
MIT License
856 stars 37 forks source link

Support for Multiple Tests #10

Open JordanForeman opened 10 years ago

JordanForeman commented 10 years ago

My particular use case involves running several tests for various types of pages as opposed to testing a single url. I'm not sure what the best way to implement this would be, but I'm envisioning something like:

perfbudget: {
    default: {
        options: {
            url: 'http://google.com',
            key: 'YOUR_KEY_HERE',
            paths: [
                '/',
                '/category',
                '/category/item'
            ]
        }
    }
}

Where the plugin would iterate over the paths provided, append them to the base URL, and kick off a test for each of the full URLs created.

Paths would be an optional parameter, and when not specified the plugin would default to the current behavior.

tkadlec commented 9 years ago

Hmmm...yeah, I follow you. Shouldn't take too much work to pull it off.

kevindixon commented 9 years ago

As a suggestion, rather than an array of paths, have additional objects per-URL with the ability over-ride any of the settings - I say this because there a frequently cases where the performance budget is different per-page (for instance, little used pages, or particularly rich pages). So, for instance:

{
    "default": {
        "options": {
            "key": "XXXXXXXXXXXXXXXXXXXXX",
            "location": "Dulles:Chrome",
            "timeout": 180,
            "connectivity": "Cable",
            "runs": 1,
            "budget": {
                "render": 5000,
                "loadTime": 7000,
                "visualComplete": 7000,
                "bytesIn": 1000000,
                "requests": 68,
                "SpeedIndex": 4800
            }
        }
    },
    "home": {
        "options": {
            "url": "http://www.google.com",
            "budget": {
                "bytesIn": 1600000
            }
        }
    },
    "home-analytics": {
        "options": {
            "url": "http://www.google.com/analytics/",
            "timeout": 60,
            "connectivity": "DSL"
        }
    }
}

This is much the same as grunt-yslow uses (https://github.com/andyshora/grunt-yslow) and it works well there.

kevindixon commented 9 years ago

As a temporary workaround, multi-perfbudget-grunt allows multiple tests to be run in a single command.