Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
PhantomJS-based web performance metrics collector and monitoring tool
JavaScript HTML

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
core
lib
modules
.gitignore
README.md
phantomas.js
run-multiple.js

README.md

phantomas

GitHub Logo

PhantomJS-based modular web performance metrics collector.

And why phantomas? Well, because :)

Requirements

Dependencies

phantomas uses the following 3rd party libraries (located in /lib directory):

Usage

Single run

phantomjs phantomas.js --url=https://github.com/macbre/phantomas  --verbose

Parameters

  • --url URL of the page to generate metrics for (required)
  • --format=[json|csv|plain] output format (plain is the default one)
  • --timeout=[seconds] timeout for phantomas run (defaults to 15 seconds)
  • --viewport=[width]x[height] phantomJS viewport dimensions (1280x1024 is the default)
  • --verbose writes debug messages to the console
  • --silent don't write anything to the console

Multiple runs

This helper script requires NodeJS.

./run-multiple.js --url=https://github.com/macbre/phantomas  --runs=5

Parameters

  • --url URL of the page to generate metrics for (required)
  • --runs number of runs to perform (defaults to 3)

Features

  • Modular approach - each metric is generated by a separate "module"
  • phantomas "core" acts as an events emitter that each module can hook into
  • JSON and CSV as available output formats for easy integration with automated reporting / monitoring tools

Metrics

Current number of metrics: 58

Units:

  • ms for time
  • bytes for size
phantomjs phantomas.js --url=https://github.com/macbre/phantomas

phantomas metrics for <https://github.com/macbre/phantomas>:

* requests: 22
* gzipRequests: 9
* redirects: 0
* notFound: 0
* timeToFirstByte: 483
* timeToLastByte: 491
* bodySize: 756080
* contentLength: 776875
* htmlCount: 1
* htmlSize: 51983
* cssCount: 2
* cssSize: 174657
* jsCount: 4
* jsSize: 389734
* imageCount: 12
* imageSize: 61573
* base64Count: 0
* base64Size: 0
* otherCount: 3
* otherSize: 78133
* cacheHits: 0
* cacheMisses: 0
* headersCount: 269
* headersSentCount: 65
* headersRecvCount: 204
* headersSize: 10258
* headersSentSize: 3850
* headersRecvSize: 6408
* assetsNotGzipped: 0
* assetsWithQueryString: 9
* httpTrafficCompleted: 1885
* domains: 5
* DOMqueries: 39
* DOMinserts: 19
* jQuerySelectors: 0
* jQueryOnDOMReadyFunctions: 0
* cookiesSent: 0
* cookiesRecv: 268
* domainsWithCookies: 1
* documentCookiesLength: 385
* documentCookiesCount: 12
* bodyHTMLSize: 49029
* commentsSize: 574
* hiddenContentSize: 16638
* whiteSpacesSize: 2375
* DOMelementsCount: 552
* DOMelementMaxDepth: 13
* iframesCount: 0
* nodesWithInlineCSS: 5
* globalVariables: 18
* localStorageEntries: 0
* smallestResponse: 35
* biggestResponse: 244180
* fastestResponse: 62
* slowestResponse: 796
* medianResponse: 98
* onDOMReadyTime: 109
* windowOnLoadTime: 1239

Requests monitor

  • requests: total number of HTTP requests made
  • gzipRequests: number of gzipped HTTP responses
  • redirects: number of HTTP redirects (either 301 or 302)
  • notFound: number of HTTP 404 responses
  • timeToFirstByte: time it took to receive the first byte of the first response
  • timeToLastByte: time it took to receive the last byte of the first response
  • bodySize: size of the content of all responses
  • contentLength: size of the content of all responses (based on Content-Length header)
  • httpTrafficCompleted: time it took to receive the last byte of the last HTTP response

Assets types

  • htmlCount: number of html responses
  • htmlSize: size of html responses
  • cssCount: number of css responses
  • cssSize: size of css responses
  • jsCount: number of js responses
  • jsSize: size of js responses
  • imageCount: number of image responses
  • imageSize: size of image responses
  • base64Count: number of base64 encoded "responses" (no HTTP request was made)
  • base64Size: size of base64 encoded "responses"
  • otherCount: number of other responses
  • otherSize: size of other responses

Cache Hits

Metrics are calculated based on X-Cache header added by Varnish / Squid servers.

  • cacheHits: number of cache hits
  • cacheMisses: number of cache misses

Headers

  • headersCount: number of requests and responses headers
  • headersSentCount: number of headers sent in requests
  • headersRecvCount: number of headers received in responses
  • headersSize: size of all headers
  • headersSentSize: size of sent headers
  • headersRecvSize: size of received headers

Domains

  • domains: number of domains used to fetch the page

Cookies

  • cookiesSent: length of cookies sent in HTTP requests
  • cookiesRecv: length of cookies received in HTTP responses
  • domainsWithCookies: number of domains with cookies set
  • documentCookiesLength: length of document.cookie
  • documentCookiesCount: number of cookies in document.cookie

DOM complexity

  • globalVariables: number of JS globals variables
  • bodyHTMLSize: the size of body tag content
  • commentsSize: the size of HTML comments on the page
  • hiddenContentSize: the size of content of hidden elements on the page (with CSS display: none)
  • whiteSpacesSize: the size of text nodes with whitespaces only
  • DOMelementsCount: total number of HTML element nodes
  • DOMelementMaxDepth: maximum level on nesting of HTML element node
  • iframesCount: number of iframe nodes
  • nodesWithInlineCSS: number of nodes with inline CSS styling (with style attribute)

DOM queries

  • DOMqueries: number of document.getElementById and document.getElementsByClassName calls
  • DOMinserts: number of DOM nodes inserts
  • jQuerySelectors: number of jQuery selectors calls (e.g. $('#foo > .bar'))
  • jQueryOnDOMReadyFunctions: number of functions bound to onDOMready event

Window performance

  • onDOMReadyTime: time it took to fire onDOMready event
  • windowOnLoadTime: time it took to fire window.load event

Requests statistics

  • smallestResponse: the size of the smallest response
  • biggestResponse: the size of the biggest response
  • fastestResponse: the time to the last byte of the fastest response
  • slowestResponse: the time to the last byte of the slowest response
  • medianResponse: median value of time to the last byte for all responses

localStorage

  • localStorageEntries: number of entries in local storage

Static assets

  • assetsNotGzipped: static assets that were not gzipped
  • assetsWithQueryString: static assets requested with query string (e.g. ?foo) in URL

Notices

phantomas apart from "raw" metrics data, when in --verbose mode, emits notices with more in-depth data:

> Requests per domain:
>  github.com: 2 request(s)
>  a248.e.akamai.net: 18 request(s)
>  ssl.google-analytics.com: 2 request(s)
>  secure.gravatar.com: 1 request(s)
>  secure.gaug.es: 1 request(s)
>
> JavaScript globals (15): html5, Modernizr, $, jQuery, jQuery17206841744652483612, $stats, moment, GitHub, DateInput, clippyCopiedCallback, debug, _gaq, _gauges, _gat, gaGlobal
>
> The smallest response (0.03 kB): https://ssl.google-analytics.com/__utm.gif?utmwv=5.3.3&utms=1&utmn=248876753&utmhn=github.com&utmcs=UTF-8&utmsr=1024x768&utmvp=1024x1280&utmsc=32-bit&utmul=pl-pl&utmje=0&utmfl=-&utmdt=macbre%2Fphantomas%20%C2%B7%20GitHub&utmhid=1544768543&utmr=-&utmp=%2Fmacbre%2Fphantomas&utmac=UA-3769691-2&utmcc=__utma%3D1.1733239656.1343076130.1343076130.1343076130.1%3B%2B__utmz%3D1.1343076130.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=qB~
> The biggest response (196.26 kB): https://a248.e.akamai.net/assets.github.com/assets/github-24e061385eeaff0ed974ca8bcf1dfc4fd96ab293.js
>
> The fastest response (5 ms): https://a248.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png
> The slowest response (870 ms): https://github.com/macbre/phantomas

For developers

Something went wrong with that request. Please try again.