<commit_before>phantomas
=========

![GitHub Logo](http://upload.wikimedia.org/wikipedia/en/a/a5/Fantomas.jpg)

PhantomJS-based modular web performance metrics collector. And why phantomas? Well, [because](http://en.wikipedia.org/wiki/Fantômas) :)

[![NPM version](https://badge.fury.io/js/phantomas.png)](http://badge.fury.io/js/phantomas)
[![Build Status](https://api.travis-ci.org/macbre/phantomas.png)](http://travis-ci.org/macbre/phantomas)

## Requirements

* [NodeJS](http://nodejs.org)
* [PhantomJS 1.9+](http://phantomjs.org/)

## Installation

```
npm install --global phantomas
```

> This will install the latest version of PhantomJS and add a symlink called ``phantomas`` (pointing to ``./bin/phantomas.js``) to your system's ``PATH``

## Features

* Modular approach - each metric is generated by a separate "module"
* phantomas "core" acts as an [events emitter](https://github.com/macbre/phantomas/wiki/Events) that each module can hook into
* in-depth metrics such as: number of events bound via jQuery, calls to ``window.write``or [complex and duplicated CSS selectors (via analyze-css)](https://github.com/macbre/analyze-css)
* JSON and CSV as available output formats for easy integration with automated reporting / monitoring tools
* easy integration with Continuous Integration tools via TAP format and assertions handling
* easy integration with other nodejs projects via CommonJS module ([see API docs](https://github.com/macbre/phantomas/wiki/npm-module))
* metrics can be emitted from JavaScript code of the page phantomas is run against (thanks to [helper functions available in window.__phantomas](https://github.com/macbre/phantomas/wiki/Phantomas-scope))

## Contributors

* [macbre](https://github.com/macbre)
* [jmervine](https://github.com/jmervine)
* [jmosney](https://github.com/jmosney)
* [umaar](https://github.com/umaar)
* [sjhcockrell](https://github.com/sjhcockrell)
* [cphoover](https://github.com/cphoover)
* [LaurentGoderre](https://github.com/LaurentGoderre)
* [kennydee](https://github.com/kennydee)
* [iNem0o](https://github.com/iNem0o)
* [stefanjudis](https://github.com/stefanjudis)
* All the [contributors](https://github.com/macbre/phantomas/graphs/contributors)

## Usage

> phantomas comes as both command line tool and CommonJS module ([see API docs](https://github.com/macbre/phantomas/wiki/npm-module)) that you can use in your nodejs projects.

### Single run

``` bash
phantomas https://github.com/macbre/phantomas --verbose
```

You can measure the performance of your site without requests to 3rd party domains (but allowing CDN that serves your static assets):

```bash
phantomas https://github.com/macbre/phantomas --verbose --no-externals --allow-domain .fastly.net
```

#### Parameters

* `--reporter=[json|csv|tap|plain|statsd|elasticsearch]` results reporter aka 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
* `--progress` shows page loading progress bar (disables verbose mode)
* `--log=[log file]` log to a given file
* `--modules=[moduleOne],[moduleTwo]` run only selected modules
* `--skip-modules=[moduleOne],[moduleTwo]` skip selected modules
* `--user-agent='Custom user agent'` provide a custom user agent (will default to something similar to ``phantomas/0.6.0 (PhantomJS/1.9.0; linux 64bit)``)
* `--config=[JSON config file]` uses JSON-formatted config file to set parameters
* `--cookie='bar=foo;domain=url'` document.cookie formatted string for setting a single cookie
* `--cookies-file=[JAR file]` specifies the file name to store the persistent Cookies
* `--no-externals` block requests to 3rd party domains
* `--allow-domain=[domain],[domain]` allow requests to given domain(s) - aka whitelist
* `--block-domain=[domain],[domain]` disallow requests to given domain(s) - aka blacklist
* `--disable-js` disable JavaScript on the page that will be loaded
* `--analyze-css` emit in-depth CSS metrics **experimental**
* `--film-strip` register film strip when page is loading **experimental**
* `--film-strip-dir=[dir path]` folder path to output film strip (default is ``./filmstrip`` directory) **experimental**
* `--assert-[metric-name]=value` assert that given metric should be less or equal the value
* `--screenshot=[file name]` render fully loaded page to a given file
* `--wait-for-selector=[CSS selector]` wait for an element matching given CSS selector before generating a report, timeout setting still applies (e.g. ``--wait-for-selector "body.loaded"``)
* `--post-load-delay=[seconds]` wait X seconds before generating a report, timeout setting still applies
* `--ignore-ssl-errors` ignores SSL errors, such as expired or self-signed certificate errors
* `--proxy=[host:port]` specifies the proxy server to use
* `--proxy-auth=[username:password]` specifies the authentication information for the proxy
* `--proxy-type=[http|socks5|none]` specifies the type of the proxy server (default is http)
* `--phone` force viewport and user agent of a mobile phone
* `--tablet` force viewport and user agent of a tablet

### Multiple runs

Simply provide ``--runs`` option:

``` bash
phantomas https://github.com/macbre/phantomas --verbose --runs 5
```

Only ``plain`` (the default one) and ``json`` reporters are currently supported in multiple runs mode.

## Metrics
<commit_msg>update with har parameter<commit_after>phantomas
=========

![GitHub Logo](http://upload.wikimedia.org/wikipedia/en/a/a5/Fantomas.jpg)

PhantomJS-based modular web performance metrics collector. And why phantomas? Well, [because](http://en.wikipedia.org/wiki/Fantômas) :)

[![NPM version](https://badge.fury.io/js/phantomas.png)](http://badge.fury.io/js/phantomas)
[![Build Status](https://api.travis-ci.org/macbre/phantomas.png)](http://travis-ci.org/macbre/phantomas)

## Requirements

* [NodeJS](http://nodejs.org)
* [PhantomJS 1.9+](http://phantomjs.org/)

## Installation

```
npm install --global phantomas
```

> This will install the latest version of PhantomJS and add a symlink called ``phantomas`` (pointing to ``./bin/phantomas.js``) to your system's ``PATH``

## Features

* Modular approach - each metric is generated by a separate "module"
* phantomas "core" acts as an [events emitter](https://github.com/macbre/phantomas/wiki/Events) that each module can hook into
* in-depth metrics such as: number of events bound via jQuery, calls to ``window.write``or [complex and duplicated CSS selectors (via analyze-css)](https://github.com/macbre/analyze-css)
* JSON and CSV as available output formats for easy integration with automated reporting / monitoring tools
* easy integration with Continuous Integration tools via TAP format and assertions handling
* easy integration with other nodejs projects via CommonJS module ([see API docs](https://github.com/macbre/phantomas/wiki/npm-module))
* metrics can be emitted from JavaScript code of the page phantomas is run against (thanks to [helper functions available in window.__phantomas](https://github.com/macbre/phantomas/wiki/Phantomas-scope))

## Contributors

* [macbre](https://github.com/macbre)
* [jmervine](https://github.com/jmervine)
* [jmosney](https://github.com/jmosney)
* [umaar](https://github.com/umaar)
* [sjhcockrell](https://github.com/sjhcockrell)
* [cphoover](https://github.com/cphoover)
* [LaurentGoderre](https://github.com/LaurentGoderre)
* [kennydee](https://github.com/kennydee)
* [iNem0o](https://github.com/iNem0o)
* [stefanjudis](https://github.com/stefanjudis)
* All the [contributors](https://github.com/macbre/phantomas/graphs/contributors)

## Usage

> phantomas comes as both command line tool and CommonJS module ([see API docs](https://github.com/macbre/phantomas/wiki/npm-module)) that you can use in your nodejs projects.

### Single run

``` bash
phantomas https://github.com/macbre/phantomas --verbose
```

You can measure the performance of your site without requests to 3rd party domains (but allowing CDN that serves your static assets):

```bash
phantomas https://github.com/macbre/phantomas --verbose --no-externals --allow-domain .fastly.net
```

#### Parameters

* `--reporter=[json|csv|tap|plain|statsd|elasticsearch]` results reporter aka 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
* `--progress` shows page loading progress bar (disables verbose mode)
* `--log=[log file]` log to a given file
* `--modules=[moduleOne],[moduleTwo]` run only selected modules
* `--skip-modules=[moduleOne],[moduleTwo]` skip selected modules
* `--user-agent='Custom user agent'` provide a custom user agent (will default to something similar to ``phantomas/0.6.0 (PhantomJS/1.9.0; linux 64bit)``)
* `--config=[JSON config file]` uses JSON-formatted config file to set parameters
* `--cookie='bar=foo;domain=url'` document.cookie formatted string for setting a single cookie
* `--cookies-file=[JAR file]` specifies the file name to store the persistent Cookies
* `--no-externals` block requests to 3rd party domains
* `--allow-domain=[domain],[domain]` allow requests to given domain(s) - aka whitelist
* `--block-domain=[domain],[domain]` disallow requests to given domain(s) - aka blacklist
* `--disable-js` disable JavaScript on the page that will be loaded
* `--analyze-css` emit in-depth CSS metrics **experimental**
* `--film-strip` register film strip when page is loading **experimental**
* `--film-strip-dir=[dir path]` folder path to output film strip (default is ``./filmstrip`` directory) **experimental**
* `--assert-[metric-name]=value` assert that given metric should be less or equal the value
* `--screenshot=[file name]` render fully loaded page to a given file
* `--har=[file name]` save HAR to a given file
* `--wait-for-selector=[CSS selector]` wait for an element matching given CSS selector before generating a report, timeout setting still applies (e.g. ``--wait-for-selector "body.loaded"``)
* `--post-load-delay=[seconds]` wait X seconds before generating a report, timeout setting still applies
* `--ignore-ssl-errors` ignores SSL errors, such as expired or self-signed certificate errors
* `--proxy=[host:port]` specifies the proxy server to use
* `--proxy-auth=[username:password]` specifies the authentication information for the proxy
* `--proxy-type=[http|socks5|none]` specifies the type of the proxy server (default is http)
* `--phone` force viewport and user agent of a mobile phone
* `--tablet` force viewport and user agent of a tablet

### Multiple runs

Simply provide ``--runs`` option:

``` bash
phantomas https://github.com/macbre/phantomas --verbose --runs 5
```

Only ``plain`` (the default one) and ``json`` reporters are currently supported in multiple runs mode.

## Metrics

{'fraction_non_alphanumeric': 0.1415562167523217, 'fraction_numerical': 0.004868812550716798, 'mean_word_length': 4.960236432025793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 42, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1904456', 'n_tokens_mistral': 3433, 'n_tokens_neox': 3257, 'n_words': 1087}