PhantomJS for Performance Testing

I am quickly becoming a real fan of PhantomJS, which as well as being an AJAX/Javascript headless browser, interacts with other equally smart tools. To do a basic performance test, use phantomJS in conjunction with yslowJS and confessJS.

EXAMPLE USING CONFESS

Generates an ASCII-art waterfall of the waits and receipts of each requested resource (akin to Firebug)

[php]phantomjs performance/confess.js *enter url* performance[/php]

EXAMPLE USING YFLOW

[php]phantomjs performance/yslow.js –info grade –format tap –threshold ‘{"overall": "B", "ycdn": 65}’ *enter url*[/php]

YSlow Options:

-h, –help output usage information
-V, –version output the version number
-i, –info specify the information to display/log (basic|grade|stats|comps|all) [all]
-f, –format specify the output results format (json|xml|plain|tap|junit) [json]
-r, –ruleset specify the YSlow performance ruleset to be used (ydefault|yslow1|yblog) [ydefault]
-b, –beacon specify an URL to log the results
-d, –dict include dictionary of results fields
-v, –verbose output beacon response information
-t, –threshold for test formats, the threshold to test scores ([0-100]|[A-F]|{JSON}) [80]
e.g.: -t B or -t 75 or -t ‘{“overall”: “B”, “ycdn”: “F”, “yexpires”: 85}’
-u, –ua “” specify the user agent string sent to server when the page requests resources
-vp, –viewport specify page viewport size WxY, where W = width and H = height [400×300]
-ch, –headers specify custom request headers, e.g.: -ch ‘{“Cookie”: “foo=bar”}’
-c, –console output page console messages (0: none, 1: message, 2: message + line + source) [0]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s