Website performance sniffer. Uses phantomjs and netsniff.js to perform multiple tests and display averaged results.
npm install -g basset
Caution! Remember that you need to have phantomjs
command in your PATH
.
basset -n 10 http://bbc.com
......F...
Average
onLoad: 4419.56 ± 1587.90 ms
requests: 82 (html: 4, css: 4, js: 34, img: 39, other: 1)
For more info: basset -h
Basset is designed to be a command-line tool which can be easily
used as a node module, so don't be affraid to require('basset')
in your project.
It's extremely easy to use basset
in your project:
- Basset needs to be initialized with an
url
andoptions
. - Method
sniff
starts the testing sequence. - Basset communicates with outer world using events (it derives from
EventEmitter
).
Basic example:
var Basset = require('basset');
var basset = new Basset('http://google.com', { repeatNum: 2 });
basset.on('end', function (results) {
average = results.average()
console.log('onLoad: ' + average.getValue('onLoad'));
});
basset.sniff();
Argument url
is required, options
are optional.
Default options:
repeatNum: 1
Run all tests (sniffers).
Emitted before starting of a first test.
Emitted after all tests stopped. Passes Statistic
intance to handler function.
See Statistic class
for more information.
var basset = new Basset('http://google.com', { repeatNum: 2 });
basset.on('end', function (results) {
var avg = results.average();
console.log(avg.getValue('onLoad'));
});
basset.sniff();
Emitted on test start.
Emitted when test gives valid result. Passes HarResult
instance to handler function.
See HarResult class
and Result class
section for more informaction.
var basset = new Basset('http://bbc.com');
basset.on('result', function (result) {
console.log(result.getValue('onLoad')); // Prints onLoad time
});
basset.sniff();
Emitted when test fails (browser error occured or something else gone wrong).
Passes Error
instance to handler function.
Emitted after test stop (after failure
or result
event).
Result
class represents a set of results. It has an array of valueNames
and you can set values only from that array. It means that if valueNames = ['foo']
you can setValue('foo', 1)
but not setValue('bar', 1)
. By default valueNames
is empty,
so you need to derive from Result
to create something functional.
Returns a copy of internal valueNames
array.
Returns value with name
. If name
isn't in valueNames
array it throws an Error
.
Sets value
. If name
isn't in valueNames
array it throws an Error
.
Returns true if name
appears in valuesNames
array.
Sets values object. If one of the values
property isn't in valueNames
it throws an Error
.
For more information about Result
class see lib/result.coffee
.
HarResult
derives from Result
. It overrides valueNames
and defines set of methods to
feed the object with a har json.
Accepts an object and gets essential information from it. If har
isn't a valid
har object it throws an Error
.
For more information about HarResult
class see lib/harResult.coffee
.
Statistic
class has many Result
intances. It can compute average
and standard deviation from them.
Add a result
to internal results
array.
Returns a Result
instance which represents an average of results
array items.
Returns a Result
instance which represent a standard deviation of results
array items.
make coffee
- generate js filesmake watch
- make sure to haveinotifywait
installed (apt-get install inotify-tools
)npm test
- run tests
0.0.1
- Initial release