Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

benchmark

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

benchmark - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

869

benchmark.js
/*!
* Benchmark.js
* Benchmark.js <http://benchmarkjs.com/>
* Copyright 2010-2011 Mathias Bynens <http://mths.be/>

@@ -10,19 +10,19 @@ * Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>

/** Detect DOM0 timeout API (performed at the bottom) */
var HAS_TIMEOUT_API,
/** Detect free variable `exports` */
var freeExports = typeof exports == 'object' && exports,
/** Detect Adobe AIR environment */
IN_AIR = isClassOf(window.runtime, 'ScriptBridgingProxyObject'),
/** Detect free variable `require` */
freeRequire = typeof require == 'function' && require,
/** Detect Java environment */
IN_JAVA = isClassOf(window.java, 'JavaPackage'),
/** Detect free variable `global` */
freeGlobal = isHostType(this, 'global') && (freeExports ? (window = global) : global),
/** Used to assign each benchmark an incrimented id */
counter = 0,
/** Used to integrity check compiled tests */
EMBEDDED_UID = +new Date,
uid = 'uid' + (+new Date),
/** Used to skip initialization of the Benchmark constructor */
HEADLESS = function() { },
/** Used to avoid hz of Infinity */
CYCLE_DIVISORS = {
divisors = {
'1': 4096,

@@ -39,19 +39,18 @@ '2': 512,

*/
T_DISTRIBUTION = {
distribution = {
'1': 12.706,'2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447,
'7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179,
'13': 2.160, '14': 2.145, '15': 2.131, '16': 2.120, '17': 2.110, '18': 2.101,
'19': 2.093, '20': 2.086, '21': 2.080, '22': 2.074, '23': 2.069, '24': 2.064,
'25': 2.060, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042,
'Infinity': 1.960
'13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101,
'19': 2.093, '20': 2.086, '21': 2.08, '22': 2.074, '23': 2.069, '24': 2.064,
'25': 2.06, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042,
'infinity': 1.96
},
/** Internal cached used by various methods */
cache = {
'counter': 0
/** Used to flag environments/features */
has = {
'air': isClassOf(window.runtime, 'ScriptBridgingProxyObject'),
'java': isClassOf(window.java, 'JavaPackage'),
'timeout': isHostType(window, 'setTimeout') && isHostType(window, 'clearTimeout')
},
/** Used in Benchmark.hasKey() */
hasOwnProperty = cache.hasOwnProperty,
/** Used to convert array-like objects to arrays */

@@ -148,9 +147,9 @@ slice = [].slice,

}
// initialize if not headless
if (name != HEADLESS) {
// treat as a headless execution, skipping initialization, if the private
// function `call` is passed as the `name` argument
if (name != call) {
counter++;
setOptions(me, options);
fn = me.fn || (me.fn = fn);
fn.uid || (fn.uid = ++cache.counter);
me.created = +new Date;
me.fn || (me.fn = fn);
me.id || (me.id = counter);
me.stats = extend({ }, me.stats);

@@ -237,7 +236,7 @@ me.times = extend({ }, me.times);

// only attempt asynchronous calls if supported
if (async && HAS_TIMEOUT_API) {
me.timerId = setTimeout(function() {
delete me.timerId;
if (async && has.timeout) {
me._timerId = setTimeout(function() {
delete me._timerId;
fn();
}, me.CYCLE_DELAY * 1e3);
}, me.delay * 1e3);
}

@@ -259,3 +258,3 @@ else {

fallback,
proto = Benchmark.prototype,
options = Benchmark.options,
timers = [],

@@ -267,2 +266,3 @@ timerNS = Date,

// lazy redefine
clock = function(me) {

@@ -274,2 +274,5 @@ var result,

// init `minTime` if needed
me.minTime || (me.minTime = me.options.minTime = options.minTime);
if (applet) {

@@ -296,3 +299,3 @@ // repair nanosecond timer

me.count = 1;
compiled = fn.compiled = compiled.call(me, timerNS).uid == EMBEDDED_UID && compiled;
compiled = fn.compiled = compiled.call(me, timerNS).uid == uid && compiled;
me.count = count;

@@ -328,6 +331,6 @@ }

timerNS.start();
while(!(measured = timerNS.microseconds()));
while (!(measured = timerNS.microseconds())) { }
} else {
start = timerNS();
while(!(measured = timerNS() - start));
while (!(measured = timerNS() - start)) { }
}

@@ -338,7 +341,7 @@ }

start = timerNS.nanoTime();
while(!(measured = timerNS.nanoTime() - start));
while (!(measured = timerNS.nanoTime() - start)) { }
}
else {
start = new timerNS;
while(!(measured = new timerNS - start));
while (!(measured = new timerNS - start)) { }
}

@@ -389,7 +392,5 @@ // check for broken timers (nanoTime may have issues)

// npm install microtime
try {
if (timerNS = typeof require == 'function' && !window.require && require('microtime').now) {
timers.push({ 'ns': timerNS, 'res': getRes('us'), 'unit': 'us' });
}
} catch(e) { }
if (timerNS = (req('microtime') || { 'now': 0 }).now) {
timers.push({ 'ns': timerNS, 'res': getRes('us'), 'unit': 'us' });
}

@@ -439,3 +440,3 @@ // pick timer with highest resolution

// embedded tests and create non-embedding fallback
code = code.replace(/\$/g, EMBEDDED_UID).split('|');
code = code.replace(/\$/g, uid).split('|');
args = code.pop();

@@ -449,3 +450,3 @@ fallback = createFunction(args,

// resolve time to achieve a percent uncertainty of 1%
proto.MIN_TIME || (proto.MIN_TIME = max(timer.res / 2 / 0.01, 0.05));
options.minTime || (options.minTime = max(timer.res / 2 / 0.01, 0.05));
return clock.apply(null, arguments);

@@ -462,12 +463,10 @@ }

function createFunction() {
var scripts,
prop = 'c' + EMBEDDED_UID;
createFunction = function(args, body) {
var parent = scripts[0].parentNode,
var sibling = document.getElementsByTagName('script')[0],
parent = sibling.parentNode,
script = document.createElement('script');
script.appendChild(document.createTextNode('Benchmark.' + prop + '=function(' + args + '){' + body + '}'));
parent.removeChild(parent.insertBefore(script, scripts[0]));
return [Benchmark[prop], delete Benchmark[prop]][0];
script.appendChild(document.createTextNode('Benchmark.' + uid + '=function(' + args + '){' + body + '}'));
parent.removeChild(parent.insertBefore(script, sibling));
return [Benchmark[uid], delete Benchmark[uid]][0];
};

@@ -478,5 +477,4 @@

try {
scripts = document.getElementsByTagName('script');
createFunction = createFunction('', 'return ' + EMBEDDED_UID)() == EMBEDDED_UID && createFunction;
} catch (e) {
createFunction = createFunction('', 'return"' + uid + '"')() == uid && createFunction;
} catch(e) {
createFunction = false;

@@ -489,11 +487,14 @@ }

/**
* Wraps a function and passes `this` to the original function as the first argument.
* Copies own/inherited properties of a source object to the destination object.
* @private
* @param {Function} fn The function to be wrapped.
* @returns {Function} The new function.
* @param {Object} destination The destination object.
* @param {Object} [source={}] The source object.
* @returns {Object} The destination object.
*/
function methodize(fn) {
return function() {
return fn.apply(this, [this].concat(slice.call(arguments)));
};
function extend(destination, source) {
source || (source = { });
for (var key in source) {
destination[key] = source[key];
}
return destination;
}

@@ -508,3 +509,3 @@

function getCriticalValue(df) {
return T_DISTRIBUTION[Math.round(df) || 1] || T_DISTRIBUTION.Infinity;
return distribution[Math.round(df) || 1] || distribution.infinity;
}

@@ -531,3 +532,4 @@

function getSource(fn) {
return trim((/^[^{]+{([\s\S]*)}\s*$/.exec(fn) || 0)[1] || '')
return ((/^[^{]+{([\s\S]*)}\s*$/.exec(fn) || 0)[1] || '')
.replace(/^\s+|\s+$/g, '')
.replace(/([^\n])$/, '$1\n');

@@ -537,2 +539,112 @@ }

/**
* Checks if an object has the specified key as a direct property.
* @private
* @param {Object} object The object to check.
* @param {String} key The key to check for.
* @returns {Boolean} Returns `true` if key is a direct property, else `false`.
*/
function hasKey(object, key) {
var result,
o = { },
hasOwnProperty = o.hasOwnProperty,
parent = (object.constructor || Object).prototype;
// for modern browsers
object = Object(object);
if (isClassOf(hasOwnProperty, 'Function')) {
result = hasOwnProperty.call(object, key);
}
// for Safari 2
else if (o.__proto__ == Object.prototype) {
object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0];
}
// for others (not as accurate)
else {
result = key in object && !(key in parent && object[key] === parent[key]);
}
return result;
}
/**
* Modify a string by replacing named tokens with matching object property values.
* @private
* @param {String} string The string to modify.
* @param {Object} object The template object.
* @returns {String} The modified string.
* @example
*
* Benchmark.interpolate('#{greet} #{who}!', {
* 'greet': 'Hello',
* 'who': 'world'
* }); // -> 'Hello world!'
*/
function interpolate(string, object) {
string = string == null ? '' : string;
each(object || { }, function(value, key) {
string = string.replace(RegExp('#\\{' + key + '\\}', 'g'), value);
});
return string;
}
/**
* Checks if an object is of the specified class.
* @private
* @param {Object} object The object.
* @param {String} name The name of the class.
* @returns {Boolean} Returns `true` if of the class, else `false`.
*/
function isClassOf(object, name) {
return object != null && {}.toString.call(object).slice(8, -1) == name;
}
/**
* Host objects can return type values that are different from their actual
* data type. The objects we are concerned with usually return non-primitive
* types of object, function, or unknown.
* @private
* @param {Mixed} object The owner of the property.
* @param {String} property The property to check.
* @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`.
*/
function isHostType(object, property) {
var type = object != null ? typeof object[property] : 'number';
return !/^(?:boolean|number|string|undefined)$/.test(type) &&
(type == 'object' ? !!object[property] : true);
}
/**
* Wraps a function and passes `this` to the original function as the first argument.
* @private
* @param {Function} fn The function to be wrapped.
* @returns {Function} The new function.
*/
function methodize(fn) {
return function() {
return fn.apply(this, [this].concat(slice.call(arguments)));
};
}
/**
* A no-operation function.
* @private
*/
function noop() {
// no operation performed
}
/**
* A wrapper around require() to suppress `module missing` errors.
* @private
* @param {String} id The module id.
* @returns {Mix} The exported module.
*/
function req(id) {
var result = null;
try {
freeExports && freeRequire && (result = freeRequire(id));
} catch(e) { }
return result;
}
/**
* Sets the options of a benchmark.

@@ -570,7 +682,11 @@ * @private

var i = -1,
result = object,
object = Object(object),
length = object.length;
if (hasKey(object, 'length') && length > -1 && length < 4294967296) {
// in Opera < 10.5 `hasKey(object, 'length')` returns false for NodeLists
if ('length' in object && length > -1 && length < 4294967296) {
while (++i < length) {
if (i in object && callback(object[i], i, object) === false) {
// in Safari 2 `i in object` is always false for NodeLists
if ((i in object || 'item' in object) && callback(object[i], i, object) === false) {
break;

@@ -586,22 +702,6 @@ }

}
return object;
return result;
}
/**
* Copies own/inherited properties of a source object to the destination object.
* @static
* @member Benchmark
* @param {Object} destination The destination object.
* @param {Object} [source={}] The source object.
* @returns {Object} The destination object.
*/
function extend(destination, source) {
source || (source = { });
for (var key in source) {
destination[key] = source[key];
}
return destination;
}
/**
* A generic bare-bones `Array#filter` solution.

@@ -640,3 +740,3 @@ * @static

b = b.stats;
return (a.mean + a.ME > b.mean + b.ME ? 1 : -1) * (callback == 'fastest' ? 1 : -1);
return (a.mean + a.moe > b.mean + b.moe ? 1 : -1) * (callback == 'fastest' ? 1 : -1);
});

@@ -665,30 +765,2 @@ result = filter(result, function(bench) {

/**
* Checks if an object has the specified key as a direct property.
* @static
* @member Benchmark
* @param {Object} object The object to check.
* @param {String} key The key to check for.
* @returns {Boolean} Returns `true` if key is a direct property, else `false`.
*/
function hasKey(object, key) {
var result,
parent = (object.constructor || Object).prototype;
// for modern browsers
object = Object(object);
if (isClassOf(hasOwnProperty, 'Function')) {
result = hasOwnProperty.call(object, key);
}
// for Safari 2
else if (cache.__proto__ == Object.prototype) {
object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0];
}
// for others (not as accurate)
else {
result = key in object && !(key in parent && object[key] === parent[key]);
}
return result;
}
/**
* A generic bare-bones `Array#indexOf` solution.

@@ -757,3 +829,3 @@ * @static

options = { 'onStart': noop, 'onCycle': noop, 'onComplete': noop },
result = slice.call(benches, 0);
result = slice.call(benches);

@@ -813,3 +885,3 @@ function execute() {

name = options.name;
args = isArray(args = 'args' in options ? options.args : []) ? args : [args];
args = isClassOf(args = 'args' in options ? options.args : [], 'Array') ? args : [args];
queued = options.queued;

@@ -819,4 +891,3 @@ }

if (name == 'run') {
async = (args[0] == null ? Benchmark.prototype.DEFAULT_ASYNC :
args[0]) && HAS_TIMEOUT_API;
async = (args[0] == null ? Benchmark.options.async : args[0]) && has.timeout;
}

@@ -830,3 +901,3 @@ // start iterating over the array

result.length = 0;
while (execute());
while (execute()) { }
}

@@ -838,62 +909,2 @@ }

/**
* Modify a string by replacing named tokens with matching object property values.
* @static
* @member Benchmark
* @param {String} string The string to modify.
* @param {Object} object The template object.
* @returns {String} The modified string.
* @example
*
* Benchmark.interpolate('#{greet} #{who}!', {
* 'greet': 'Hello',
* 'who': 'world'
* }); // -> 'Hello world!'
*/
function interpolate(string, object) {
string = string == null ? '' : string;
each(object || { }, function(value, key) {
string = string.replace(RegExp('#\\{' + key + '\\}', 'g'), String(value));
});
return string;
}
/**
* Determines if the given value is an array.
* @static
* @member Benchmark
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true` if value is an array, else `false`.
*/
function isArray(value) {
return isClassOf(value, 'Array');
}
/**
* Checks if an object is of the specified class.
* @static
* @member Benchmark
* @param {Object} object The object.
* @param {String} name The name of the class.
* @returns {Boolean} Returns `true` if of the class, else `false`.
*/
function isClassOf(object, name) {
return object != null && {}.toString.call(object).slice(8, -1) == name;
}
/**
* Host objects can return type values that are different from their actual
* data type. The objects we are concerned with usually return non-primitive
* types of object, function, or unknown.
* @static
* @member Benchmark
* @param {Mixed} object The owner of the property.
* @param {String} property The property to check.
* @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`.
*/
function isHostType(object, property) {
return !/^(?:boolean|number|string|undefined)$/
.test(typeof object[property]) && !!object[property];
}
/**
* Creates a string of joined array values or object key-value pairs.

@@ -909,3 +920,3 @@ * @static

var pairs = [];
if (isArray(object)) {
if (isClassOf(object, 'Array')) {
pairs = object;

@@ -938,11 +949,2 @@ }

/**
* A no-operation function.
* @static
* @member Benchmark
*/
function noop() {
// no operation performed
}
/**
* Retrieves the value of a specified property from all items in an array.

@@ -977,13 +979,2 @@ * @static

/**
* A generic bare-bones `String#trim` solution.
* @static
* @member Benchmark
* @param {String} string The string to trim.
* @returns {String} The trimmed string.
*/
function trim(string) {
return String(string).replace(/^\s+/, '').replace(/\s+$/, '');
}
/*--------------------------------------------------------------------------*/

@@ -1029,3 +1020,3 @@

var me = this,
bench = new Benchmark(HEADLESS);
bench = new Benchmark(call);

@@ -1148,14 +1139,15 @@ Benchmark.call(bench, name, fn, options);

* @member Benchmark, Benchmark.Suite
* @param {String} type The event type.
* @param {String|Object} type The event type or object.
* @returns {Boolean} Returns `true` if all listeners were executed, else `false`.
*/
function emit(type) {
var me = this,
args = slice.call(arguments, 1),
event = typeof type == 'string' ? { 'type': type } : type,
args = (arguments[0] = event, slice.call(arguments)),
events = me.events,
listeners = events && events[type] || [],
listeners = events && events[event.type] || [],
successful = true;
each(listeners, function(listener) {
if (listener.apply(me, args) === false) {
successful = false;
each(listeners.slice(), function(listener) {
if (!(successful = listener.apply(me, args) !== false)) {
return successful;

@@ -1228,5 +1220,5 @@ }

if (me.running) {
if (me.timerId && HAS_TIMEOUT_API) {
clearTimeout(me.timerId);
delete me.timerId;
if (me._timerId && has.timeout) {
clearTimeout(me._timerId);
delete me._timerId;
}

@@ -1281,3 +1273,3 @@ // set running as NaN so reset() will detect it as falsey and *not* call abort(),

tstat = (a.mean - b.mean) / sqrt(pooled * (1 / a.size + 1 / b.size)),
near = abs(1 - a.mean / b.mean) < 0.055 && a.RME < 3 && b.RME < 3;
near = abs(1 - a.mean / b.mean) < 0.055 && a.rme < 3 && b.rme < 3;

@@ -1305,4 +1297,3 @@ // check if the means aren't close and the t-statistic is significant

}
else if (!isClassOf(value, 'Function') &&
key != 'created' && value != other) {
else if (!isClassOf(value, 'Function') && value != other) {
pair[1][key] = value;

@@ -1339,6 +1330,7 @@ changed = true;

hz = me.hz,
id = me.id,
stats = me.stats,
size = stats.size,
pm = IN_JAVA ? '+/-' : '\xb1',
result = me.name || me.id || ('<Test #' + me.fn.uid + '>');
pm = has.java ? '+/-' : '\xb1',
result = me.name || (typeof id == 'number' ? '<Test #' + id + '>' : id);

@@ -1349,3 +1341,3 @@ if (error) {

result += ' x ' + formatNumber(hz.toFixed(hz < 100 ? 2 : 0)) + ' ops/sec ' + pm +
stats.RME.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)';
stats.rme.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)';
}

@@ -1366,3 +1358,3 @@ return result;

sample = [],
runCount = me.INIT_RUN_COUNT;
initCount = me.initCount;

@@ -1372,3 +1364,3 @@ function enqueue(count) {

queue.push(me.clone({
'computing': me,
'_host': me,
'events': { 'start': [update], 'cycle': [update] }

@@ -1387,3 +1379,3 @@ }));

me.times.period = clone.times.period;
me.INIT_RUN_COUNT = clone.INIT_RUN_COUNT;
me.initCount = clone.initCount;
me.emit('cycle');

@@ -1398,3 +1390,3 @@ }

// on start
clone.count = me.INIT_RUN_COUNT;
clone.count = me.initCount;
}

@@ -1417,3 +1409,3 @@ } else if (me.aborted) {

elapsed = (now - times.start) / 1e3,
maxedOut = elapsed > me.MAX_TIME_ELAPSED,
maxedOut = elapsed > me.maxTime,
size = sample.push(clone.times.period),

@@ -1452,5 +1444,5 @@ varOf = function(sum, x) { return sum + pow(x - mean, 2); };

extend(me.stats, {
'ME': moe,
'RME': rme,
'SEM': sem,
'moe': moe,
'rme': rme,
'sem': sem,
'deviation': sd,

@@ -1468,3 +1460,3 @@ 'mean': mean,

}
me.INIT_RUN_COUNT = runCount;
me.initCount = initCount;
me.emit('complete');

@@ -1477,3 +1469,3 @@ }

// init sample/queue and begin
enqueue(me.MIN_SAMPLE_SIZE);
enqueue(me.minSamples);
invoke(queue, { 'name': 'run', 'args': async, 'queued': true, 'onCycle': evaluate });

@@ -1497,3 +1489,3 @@ }

count = me.count,
host = me.computing,
host = me._host,
times = me.times;

@@ -1508,4 +1500,5 @@

try {
// host `minTime` is set to `Benchmark.options.minTime` in `clock()`
clocked = clock(host);
minTime = me.MIN_TIME;
minTime = me.minTime = host.minTime;
} catch(e) {

@@ -1528,11 +1521,11 @@ me.abort();

// avoid working our way up to this next time
me.INIT_RUN_COUNT = count;
me.initCount = count;
if (me.running) {
// tests may clock at 0 when INIT_RUN_COUNT is a small number,
// tests may clock at `0` when `initCount` is a small number,
// to avoid that we set its count to something a bit higher
if (!clocked && (divisor = CYCLE_DIVISORS[me.cycles]) != null) {
if (!clocked && (divisor = divisors[me.cycles]) != null) {
count = Math.floor(4e6 / divisor);
}
// calculate how many more iterations it will take to achive the MIN_TIME
// calculate how many more iterations it will take to achive the `minTime`
if (count <= me.count) {

@@ -1553,7 +1546,7 @@ count += Math.ceil((minTime - clocked) / period);

} else {
// fix TraceMonkey bug
// fix TraceMonkey bug associated with clock fallbacks
// http://bugzil.la/509069
if (window.Benchmark == Benchmark) {
window.Benchmark = 1;
window.Benchmark = Benchmark;
if (window['Benchmark'] == Benchmark) {
window['Benchmark'] = 1;
window['Benchmark'] = Benchmark;
}

@@ -1569,8 +1562,9 @@ me.emit('complete');

me.count = me.INIT_RUN_COUNT;
me.count = me.initCount;
me.times.start = +new Date;
me.emit('start');
async = (async == null ? me.DEFAULT_ASYNC : async) && HAS_TIMEOUT_API;
if (me.computing) {
async = (async == null ? me.async : async) && has.timeout;
if (me._host) {
cycle();

@@ -1585,187 +1579,2 @@ } else {

/**
* Platform object containing browser name, version, and operating system.
* @static
* @member Benchmark
* @type Object
*/
Benchmark.platform = (function() {
var me = this,
alpha = IN_JAVA ? 'a' : '\u03b1',
beta = IN_JAVA ? 'b' : '\u03b2',
description = [],
doc = window.document || {},
nav = window.navigator || {},
ua = nav.userAgent || 'unknown platform',
layout = /Gecko|Trident|WebKit/.exec(ua),
data = { '6.1': 'Server 2008 R2 / 7', '6.0': 'Server 2008 / Vista', '5.2': 'Server 2003 / XP x64', '5.1': 'XP', '5.0': '2000', '4.0': 'NT', '4.9': 'ME' },
name = 'Avant Browser,Camino,Epiphany,Fennec,Flock,Galeon,GreenBrowser,iCab,Iron,K-Meleon,Konqueror,Lunascape,Maxthon,Minefield,Nook Browser,RockMelt,SeaMonkey,Sleipnir,SlimBrowser,Sunrise,Swiftfox,Opera Mini,Opera,Chrome,Firefox,IE,Safari',
os = 'Android,Cygwin,SymbianOS,webOS[ /]\\d,Linux,Mac OS(?: X)?,Macintosh,Windows 98;,Windows ',
product = 'BlackBerry\\s?\\d+,iP[ao]d,iPhone,Kindle,Nokia,Nook,PlayBook,Samsung,Xoom',
version = isClassOf(window.opera, 'Opera') && opera.version();
function format(string) {
// trim and conditionally capitalize
return /^(?:webOS|i(?:OS|P))/.test(string = trim(string)) ? string :
string.charAt(0).toUpperCase() + string.slice(1);
}
name = reduce(name.split(','), function(name, guess) {
return name || RegExp(guess + '\\b', 'i').exec(ua) && guess;
});
product = reduce(product.split(','), function(product, guess) {
if (!product && (product = RegExp(guess + '[^ ();-]*', 'i').exec(ua))) {
// correct character case and split by forward slash
if ((product = String(product).replace(RegExp(guess = /\w+/.exec(guess), 'i'), guess).split('/'))[1]) {
if (/[\d.]+/.test(product[0])) {
version = version || product[1];
} else {
product[0] += ' ' + product[1];
}
}
product = format(product[0].replace(/([a-z])(\d)/i, '$1 $2').split('-')[0]);
}
return product;
});
os = reduce(os.split(','), function(os, guess) {
if (!os && (os = RegExp(guess + '[^();/-]*').exec(ua))) {
// platform tokens defined at
// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
if (/^win/i.test(os) && (data = data[0/*opera fix*/,/[456]\.\d/.exec(os)])) {
os = 'Windows ' + data;
}
// normalize iOS
else if (/^iP/.test(product)) {
name || (name = 'Safari');
os = 'iOS' + ((data = /\bOS ([\d_]+)/.exec(ua)) ? ' ' + data[1] : '');
}
// cleanup
os = String(os).replace(RegExp(guess = /\w+/.exec(guess), 'i'), guess)
.replace(/\/(\d)/, ' $1').replace(/_/g, '.').replace(/x86\.64/g, 'x86_64')
.replace('Macintosh', 'Mac OS').replace(/(OS X) Mach$/, '$1').split(' on ')[0];
}
return os;
});
// detect simulator
if (/Simulator/i.exec(ua)) {
product = (product ? product + ' ' : '') + 'Simulator';
}
// detect non Firefox Gecko/Safari WebKit based browsers
if (ua && (data = /^(?:Firefox|Safari|null)/.exec(name))) {
if (name && !product && /[/,]/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
name = null;
}
if ((data = product || os) && !/^(?:iP|Lin|Mac|Win)/.test(data)) {
name = /[a-z]+/i.exec(/^And/.test(os) && os || data) + ' Browser';
}
}
// detect non Opera versions
if (!version) {
version = reduce(['version', name, 'AdobeAIR', 'Firefox', 'NetFront'], function(version, guess) {
return version || (RegExp(guess + '(?:-[\\d.]+/|[ /-])([^ ();/-]*)', 'i').exec(ua) || 0)[1] || null;
});
}
// detect server-side js
if (me && isHostType(me, 'global')) {
if (typeof exports == 'object' && exports) {
if (me == window && typeof system == 'object' && (data = system)) {
name = data.global == global ? 'Narwhal' : 'RingoJS';
os = data.os || null;
}
else if (typeof process == 'object' && (data = process)) {
name = 'Node.js';
version = /[\d.]+/.exec(data.version)[0];
os = data.platform;
}
} else if (isClassOf(me.environment, 'Environment')) {
name = 'Rhino';
}
if (IN_JAVA && !os) {
os = String(java.lang.System.getProperty('os.name'));
}
}
// detect Adobe AIR
else if (IN_AIR) {
name = 'Adobe AIR';
os = runtime.flash.system.Capabilities.os;
}
// detect PhantomJS
else if (isClassOf(data = window.phantom, 'RuntimeObject')) {
name = 'PhantomJS';
version = (data = data.version) && (data.major + '.' + data.minor + '.' + data.patch);
}
// detect IE compatibility mode
else if (typeof doc.documentMode == 'number' && (data = /Trident\/(\d+)/.exec(ua))) {
version = [version, doc.documentMode];
version[1] = (data = +data[1] + 4) != version[1] ? (layout = null, description.push('running in IE ' + version[1] + ' mode'), data) : version[1];
version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
}
// detect release phases
if (version && (data = /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) || /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + nav.appMinorVersion))) {
version = version.replace(RegExp(data + '\\+?$'), '') + (/^b/i.test(data) ? beta : alpha) + (/\d+\+?/.exec(data) || '');
}
// detect Maxthon's unreliable version info
if (/^Max/.test(name)) {
version = version && version.replace(/\.[.\d]*/, '.x');
}
// detect Firefox nightly
else if (/^Min/.test(name)) {
name = 'Firefox';
version = RegExp(alpha + '|' + beta + '|null').test(version) ? version : version + alpha;
}
// detect mobile
else if (name && (!product || name == 'IE') && !/Bro/.test(name) && /Mobi/.test(ua)) {
name += ' Mobile';
}
// detect unspecified Chrome/Safari versions
if (data = (/AppleWebKit\/(\d+(?:\.\d+)?)/.exec(ua) || 0)[1]) {
if (/^And/.exec(os)) {
data = data < 530 ? 1 : data < 532 ? 2 : data < 532.5 ? 3 : data < 533 ? 4 : data < 534.3 ? 5 : data < 534.7 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : '10';
layout = 'like Chrome';
} else {
data = data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : '4';
layout = 'like Safari';
}
layout += ' ' + (data += typeof data == 'number' ? '.x' : '+');
version = name == 'Safari' && (!version || parseInt(version) > 45) ? data : version;
}
// detect platform preview
if (RegExp(alpha + '|' + beta).test(version) && typeof external == 'object' && !external) {
layout = layout && !/like /.test(layout) ? 'rendered by ' + layout : layout;
description.unshift('platform preview');
}
// add layout engine
if (layout && /Ado|Bro|Lun|Max|Pha|Sle/.test(name)) {
description.push(layout);
}
// combine contextual information
if (description.length) {
description = ['(' + description.join('; ') + ')'];
}
// append product
if (product && String(name).indexOf(product) < 0) {
description.push('on ' + product);
}
// add browser/os architecture
if (/\b(?:WOW|x|IA)64\b/.test(ua)) {
os = os && os + (/64/.test(os) ? '' : ' x64');
if (name && (/WOW64/.test(ua) || /\w(?:86|32)$/.test(nav.cpuClass || nav.platform))) {
description.unshift('x86');
}
}
return {
'version': name && version && description.unshift(version) && version,
'name': name && description.unshift(name) && name,
'os': name && (os = os && format(os)) && description.push(product ? '(' + os + ')' : 'on ' + os) && os,
'product': product,
'description': description.length ? description.join(' ') : ua,
'toString': function() { return this.description; }
};
}());
/*--------------------------------------------------------------------------*/
extend(Benchmark, {

@@ -1779,3 +1588,3 @@

*/
'version': '0.2.1',
'version': '0.2.2',

@@ -1788,10 +1597,111 @@ /**

*/
'options': { },
'options': {
/**
* A flag to indicate methods will run asynchronously by default.
* @member Benchmark.options
* @type Boolean
*/
'async': false,
/**
* The delay between test cycles (secs).
* @member Benchmark.options
* @type Number
*/
'delay': 0.005,
/**
* The default number of times to execute a test on a benchmark's first cycle.
* @member Benchmark.options
* @type Number
*/
'initCount': 5,
/**
* The maximum time a benchmark is allowed to run before finishing (secs).
* @member Benchmark.options
* @type Number
*/
'maxTime': 5,
/**
* The minimum sample size required to perform statistical analysis.
* @member Benchmark.options
* @type Number
*/
'minSamples': 5,
/**
* The time needed to reduce the percent uncertainty of measurement to 1% (secs).
* @member Benchmark.options
* @type Number
*/
'minTime': 0
},
/**
* Platform object containing browser name, version, and operating system.
* @static
* @member Benchmark
* @type Object
*/
'platform': req('platform') || window.platform || {
/**
* The platform description.
* @member Benchmark.platform
* @type {String}
*/
'description': window.navigator && navigator.userAgent || 'unknown platform',
/**
* The name of the browser layout engine.
* @member Benchmark.platform
* @type {String|Null}
*/
'layout': null,
/**
* The name of the product hosting the browser.
* @member Benchmark.platform
* @type {String|Null}
*/
'product': null,
/**
* The name of the browser/environment.
* @member Benchmark.platform
* @type {String|Null}
*/
'name': null,
/**
* The name of the operating system.
* @member Benchmark.platform
* @type {String|Null}
*/
'os': null,
/**
* The browser/environment version.
* @member Benchmark.platform
* @type {String|Null}
*/
'version': null,
/**
* Return platform description when the platform object is coerced to a string.
* @member Benchmark.platform
* @type Function
* @returns {String} The platform description.
*/
'toString': function() {
return this.description;
}
},
// generic Array#forEach/for-in
'each': each,
// copy properties to another object
'extend': extend,
// generic Array#filter

@@ -1803,5 +1713,2 @@ 'filter': filter,

// xbrowser Object#hasOwnProperty
'hasKey': hasKey,
// generic Array#indexOf

@@ -1813,14 +1720,2 @@ 'indexOf': indexOf,

// modifies a string using a template object
'interpolate': interpolate,
// xbrowser Array.isArray
'isArray': isArray,
// checks internal [[Class]] of an object
'isClassOf': isClassOf,
// checks if an object's property is a non-primitive value
'isHostType': isHostType,
// generic Array#join for arrays and objects

@@ -1832,5 +1727,2 @@ 'join': join,

// no operation
'noop': noop,
// retrieves a property value from each item in an array

@@ -1840,6 +1732,3 @@ 'pluck': pluck,

// generic Array#reduce
'reduce': reduce,
// generic String#trim
'trim': trim
'reduce': reduce
});

@@ -1855,44 +1744,2 @@

/**
* The delay between test cycles (secs).
* @member Benchmark
* @type Number
*/
'CYCLE_DELAY': 0.005,
/**
* A flag to indicate methods will run asynchronously by default.
* @member Benchmark
* @type Boolean
*/
'DEFAULT_ASYNC': false,
/**
* The default number of times to execute a test on a benchmark's first cycle.
* @member Benchmark
* @type Number
*/
'INIT_RUN_COUNT': 5,
/**
* The maximum time a benchmark is allowed to run before finishing (secs).
* @member Benchmark
* @type Number
*/
'MAX_TIME_ELAPSED': 5,
/**
* The minimum sample size required to perform statistical analysis.
* @member Benchmark
* @type Number
*/
'MIN_SAMPLE_SIZE': 5,
/**
* The time needed to reduce the percent uncertainty of measurement to 1% (secs).
* @member Benchmark
* @type Number
*/
'MIN_TIME': 0,
/**
* The number of times a test was executed.

@@ -1905,9 +1752,2 @@ * @member Benchmark

/**
* A timestamp of when the benchmark was created.
* @member Benchmark
* @type Number
*/
'created': 0,
/**
* The number of cycles performed while benchmarking.

@@ -1998,3 +1838,3 @@ * @member Benchmark

*/
'ME': 0,
'moe': 0,

@@ -2006,3 +1846,3 @@ /**

*/
'RME': 0,
'rme': 0,

@@ -2014,3 +1854,3 @@ /**

*/
'SEM': 0,
'sem': 0,

@@ -2264,22 +2104,23 @@ /**

// expose Benchmark
if (typeof exports == 'object' && exports && typeof global == 'object' && global) {
window = global;
if (typeof module == 'object' && module && module.exports == exports) {
if (freeExports) {
if (typeof module == 'object' && module && module.exports == freeExports) {
module.exports = Benchmark;
} else {
exports.Benchmark = Benchmark;
freeExports.Benchmark = Benchmark;
}
} else if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
define(['platform'], function(platform) {
Benchmark.platform = platform;
return Benchmark;
});
} else {
window.Benchmark = Benchmark;
// use square bracket notation so Closure Compiler won't mung `Benchmark`
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
window['Benchmark'] = Benchmark;
}
// trigger clock's lazy define early to avoid a security error
if (IN_AIR) {
clock({ 'fn': noop, 'count': 1 });
if (has.air) {
clock({ 'fn': noop, 'count': 1, 'options': { } });
}
// feature detect
HAS_TIMEOUT_API = isHostType(window, 'setTimeout') &&
isHostType(window, 'clearTimeout');
}(this));

@@ -10,22 +10,12 @@ # Benchmark.js API documentation

* [`Benchmark`](#Benchmark)
* [`Benchmark.options`](#Benchmark.options)
* [`Benchmark.platform`](#Benchmark.platform)
* [`Benchmark.version`](#Benchmark.version)
* [`Benchmark.each`](#Benchmark.each)
* [`Benchmark.extend`](#Benchmark.extend)
* [`Benchmark.filter`](#Benchmark.filter)
* [`Benchmark.formatNumber`](#Benchmark.formatNumber)
* [`Benchmark.hasKey`](#Benchmark.hasKey)
* [`Benchmark.indexOf`](#Benchmark.indexOf)
* [`Benchmark.interpolate`](#Benchmark.interpolate)
* [`Benchmark.invoke`](#Benchmark.invoke)
* [`Benchmark.isArray`](#Benchmark.isArray)
* [`Benchmark.isClassOf`](#Benchmark.isClassOf)
* [`Benchmark.isHostType`](#Benchmark.isHostType)
* [`Benchmark.join`](#Benchmark.join)
* [`Benchmark.map`](#Benchmark.map)
* [`Benchmark.noop`](#Benchmark.noop)
* [`Benchmark.pluck`](#Benchmark.pluck)
* [`Benchmark.reduce`](#Benchmark.reduce)
* [`Benchmark.trim`](#Benchmark.trim)

@@ -38,14 +28,8 @@ <!-- /div -->

## `Benchmark.prototype`
* [`Benchmark#CYCLE_DELAY`](#Benchmark:CYCLE_DELAY)
* [`Benchmark#DEFAULT_ASYNC`](#Benchmark:DEFAULT_ASYNC)
* [`Benchmark#INIT_RUN_COUNT`](#Benchmark:INIT_RUN_COUNT)
* [`Benchmark#MAX_TIME_ELAPSED`](#Benchmark:MAX_TIME_ELAPSED)
* [`Benchmark#MIN_SAMPLE_SIZE`](#Benchmark:MIN_SAMPLE_SIZE)
* [`Benchmark#MIN_TIME`](#Benchmark:MIN_TIME)
* [`Benchmark#aborted`](#Benchmark:aborted)
* [`Benchmark#count`](#Benchmark:count)
* [`Benchmark#created`](#Benchmark:created)
* [`Benchmark#cycles`](#Benchmark:cycles)
* [`Benchmark#error`](#Benchmark:error)
* [`Benchmark#hz`](#Benchmark:hz)
* [`Benchmark#on`](#Benchmark:on)
* [`Benchmark#running`](#Benchmark:running)

@@ -57,3 +41,2 @@ * [`Benchmark#abort`](#Benchmark:abort)

* [`Benchmark#emit`](#Benchmark:emit)
* [`Benchmark#on`](#Benchmark:on)
* [`Benchmark#removeAllListeners`](#Benchmark:removeAllListeners)

@@ -66,10 +49,53 @@ * [`Benchmark#removeListener`](#Benchmark:removeListener)

* [`Benchmark#toString`](#Benchmark:toString)
<!-- /div -->
<!-- div -->
## `Benchmark.options`
* [`Benchmark.options`](#Benchmark.options)
* [`Benchmark.options.async`](#Benchmark.options.async)
* [`Benchmark.options.delay`](#Benchmark.options.delay)
* [`Benchmark.options.initCount`](#Benchmark.options.initCount)
* [`Benchmark.options.maxTime`](#Benchmark.options.maxTime)
* [`Benchmark.options.minSamples`](#Benchmark.options.minSamples)
* [`Benchmark.options.minTime`](#Benchmark.options.minTime)
<!-- /div -->
<!-- div -->
## `Benchmark.platform`
* [`Benchmark.platform`](#Benchmark.platform)
* [`Benchmark.platform.description`](#Benchmark.platform.description)
* [`Benchmark.platform.layout`](#Benchmark.platform.layout)
* [`Benchmark.platform.name`](#Benchmark.platform.name)
* [`Benchmark.platform.os`](#Benchmark.platform.os)
* [`Benchmark.platform.product`](#Benchmark.platform.product)
* [`Benchmark.platform.version`](#Benchmark.platform.version)
* [`Benchmark.platform.toString`](#Benchmark.platform.toString)
<!-- /div -->
<!-- div -->
## `Benchmark#stats`
* [`Benchmark#stats`](#Benchmark:stats)
* [`Benchmark#stats.ME`](#Benchmark:stats.ME)
* [`Benchmark#stats.RME`](#Benchmark:stats.RME)
* [`Benchmark#stats.SEM`](#Benchmark:stats.SEM)
* [`Benchmark#stats.deviation`](#Benchmark:stats.deviation)
* [`Benchmark#stats.mean`](#Benchmark:stats.mean)
* [`Benchmark#stats.moe`](#Benchmark:stats.moe)
* [`Benchmark#stats.rme`](#Benchmark:stats.rme)
* [`Benchmark#stats.sem`](#Benchmark:stats.sem)
* [`Benchmark#stats.size`](#Benchmark:stats.size)
* [`Benchmark#stats.variance`](#Benchmark:stats.variance)
<!-- /div -->
<!-- div -->
## `Benchmark#times`
* [`Benchmark#times`](#Benchmark:times)

@@ -89,3 +115,2 @@ * [`Benchmark#times.cycle`](#Benchmark:times.cycle)

* [`Benchmark.Suite`](#Benchmark.Suite)
* [`Benchmark.Suite.options`](#Benchmark.Suite.options)

@@ -100,9 +125,10 @@ <!-- /div -->

* [`Benchmark.Suite#length`](#Benchmark.Suite:length)
* [`Benchmark.Suite#on`](#Benchmark:on)
* [`Benchmark.Suite#running`](#Benchmark.Suite:running)
* [`Benchmark.Suite#abort`](#Benchmark.Suite:abort)
* [`Benchmark.Suite#add`](#Benchmark.Suite:add)
* [`Benchmark.Suite#addListener`](#Benchmark.Suite:addListener)
* [`Benchmark.Suite#addListener`](#Benchmark:addListener)
* [`Benchmark.Suite#clone`](#Benchmark.Suite:clone)
* [`Benchmark.Suite#each`](#Benchmark.Suite:each)
* [`Benchmark.Suite#emit`](#Benchmark.Suite:emit)
* [`Benchmark.Suite#emit`](#Benchmark:emit)
* [`Benchmark.Suite#filter`](#Benchmark.Suite:filter)

@@ -112,7 +138,6 @@ * [`Benchmark.Suite#indexOf`](#Benchmark.Suite:indexOf)

* [`Benchmark.Suite#map`](#Benchmark.Suite:map)
* [`Benchmark.Suite#on`](#Benchmark.Suite:on)
* [`Benchmark.Suite#pluck`](#Benchmark.Suite:pluck)
* [`Benchmark.Suite#reduce`](#Benchmark.Suite:reduce)
* [`Benchmark.Suite#removeAllListeners`](#Benchmark.Suite:removeAllListeners)
* [`Benchmark.Suite#removeListener`](#Benchmark.Suite:removeListener)
* [`Benchmark.Suite#removeAllListeners`](#Benchmark:removeAllListeners)
* [`Benchmark.Suite#removeListener`](#Benchmark:removeListener)
* [`Benchmark.Suite#reset`](#Benchmark.Suite:reset)

@@ -124,5 +149,13 @@ * [`Benchmark.Suite#run`](#Benchmark.Suite:run)

<!-- div -->
## `Benchmark.Suite.options`
* [`Benchmark.Suite.options`](#Benchmark.Suite.options)
<!-- /div -->
<!-- /div -->
<!-- div -->

@@ -137,3 +170,3 @@

### <a id="Benchmark" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L130" title="View in source">`Benchmark(name, fn [, options={}])`</a>
### <a id="Benchmark" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L129" title="View in source">`Benchmark(name, fn [, options={}])`</a>
Benchmark constructor.

@@ -148,53 +181,55 @@ [&#9650;][1]

#### Example
// basic usage
var bench = new Benchmark(fn);
~~~ js
// basic usage
var bench = new Benchmark(fn);
// or using a name first
var bench = new Benchmark('foo', fn);
// or using a name first
var bench = new Benchmark('foo', fn);
// or with options
var bench = new Benchmark('foo', fn, {
// or with options
var bench = new Benchmark('foo', fn, {
// displayed by Benchmark#toString if `name` is not available
'id': 'xyz',
// displayed by Benchmark#toString if `name` is not available
'id': 'xyz',
// called when the benchmark starts running
'onStart': onStart,
// called when the benchmark starts running
'onStart': onStart,
// called after each run cycle
'onCycle': onCycle,
// called after each run cycle
'onCycle': onCycle,
// called when aborted
'onAbort': onAbort,
// called when aborted
'onAbort': onAbort,
// called when a test errors
'onError': onError,
// called when a test errors
'onError': onError,
// called when reset
'onReset': onReset,
// called when reset
'onReset': onReset,
// called when the benchmark completes running
'onComplete': onComplete,
// called when the benchmark completes running
'onComplete': onComplete,
// compiled/called before the test loop
'setup': setup,
// compiled/called before the test loop
'setup': setup,
// compiled/called after the test loop
'teardown': teardown
});
// compiled/called after the test loop
'teardown': teardown
});
// or options only
var bench = new Benchmark({
// or options only
var bench = new Benchmark({
// benchmark name
'name': 'foo',
// benchmark name
'name': 'foo',
// benchmark test function
'fn': fn
});
// benchmark test function
'fn': fn
});
// a test's `this` binding is set to the benchmark instance
var bench = new Benchmark('foo', function() {
'My name is '.concat(this.name); // My name is foo
});
// a test's `this` binding is set to the benchmark instance
var bench = new Benchmark('foo', function() {
'My name is '.concat(this.name); // My name is foo
});
~~~

@@ -206,21 +241,10 @@ <!-- /div -->

### <a id="Benchmark.options" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1735" title="View in source">`Benchmark.options`</a>
*(Object)*: The default options object copied by instances.
## `Benchmark`
### <a id="Benchmark" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L129" title="View in source">`Benchmark(name, fn [, options={}])`</a>
Benchmark constructor.
[&#9650;][1]
<!-- /div -->
<!-- div -->
### <a id="Benchmark.platform" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1540" title="View in source">`Benchmark.platform`</a>
*(Object)*: Platform object containing browser name, version, and operating system.
[&#9650;][1]
<!-- /div -->
<!-- div -->
### <a id="Benchmark.version" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1727" title="View in source">`Benchmark.version`</a>
### <a id="Benchmark.version" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1536" title="View in source">`Benchmark.version`</a>
*(String)*: The version number.

@@ -234,5 +258,4 @@ [&#9650;][1]

### <a id="Benchmark.each" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L549" title="View in source">`Benchmark.each(object, callback)`</a>
### <a id="Benchmark.each" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L661" title="View in source">`Benchmark.each(object, callback)`</a>
A bare-bones `Array#forEach`/`for-in` own property solution.
Callbacks may terminate the loop by explicitly returning `false`.
[&#9650;][1]

@@ -245,3 +268,3 @@

#### Returns
*(Array|Object)*: Returns the object iterated over.
*(Array, Object)*: Returns the object iterated over.

@@ -253,19 +276,3 @@ <!-- /div -->

### <a id="Benchmark.extend" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L577" title="View in source">`Benchmark.extend(destination [, source={}])`</a>
Copies own/inherited properties of a source object to the destination object.
[&#9650;][1]
#### Arguments
1. `destination` *(Object)*: The destination object.
2. `[source={}]` *(Object)*: The source object.
#### Returns
*(Object)*: The destination object.
<!-- /div -->
<!-- div -->
### <a id="Benchmark.filter" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L608" title="View in source">`Benchmark.filter(array, callback)`</a>
### <a id="Benchmark.filter" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L708" title="View in source">`Benchmark.filter(array, callback)`</a>
A generic bare-bones `Array#filter` solution.

@@ -282,15 +289,17 @@ [&#9650;][1]

#### Example
// get odd numbers
Benchmark.filter([1, 2, 3, 4, 5], function(n) {
return n % 2;
}); // -> [1, 3, 5];
~~~ js
// get odd numbers
Benchmark.filter([1, 2, 3, 4, 5], function(n) {
return n % 2;
}); // -> [1, 3, 5];
// get fastest benchmarks
Benchmark.filter(benches, 'fastest');
// get fastest benchmarks
Benchmark.filter(benches, 'fastest');
// get slowest benchmarks
Benchmark.filter(benches, 'slowest');
// get slowest benchmarks
Benchmark.filter(benches, 'slowest');
// get benchmarks that completed without erroring
Benchmark.filter(benches, 'successful');
// get benchmarks that completed without erroring
Benchmark.filter(benches, 'successful');
~~~

@@ -302,3 +311,3 @@ <!-- /div -->

### <a id="Benchmark.formatNumber" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L637" title="View in source">`Benchmark.formatNumber(number)`</a>
### <a id="Benchmark.formatNumber" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L737" title="View in source">`Benchmark.formatNumber(number)`</a>
Converts a number to a more readable comma-separated string representation.

@@ -318,19 +327,3 @@ [&#9650;][1]

### <a id="Benchmark.hasKey" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L650" title="View in source">`Benchmark.hasKey(object, key)`</a>
Checks if an object has the specified key as a direct property.
[&#9650;][1]
#### Arguments
1. `object` *(Object)*: The object to check.
2. `key` *(String)*: The key to check for.
#### Returns
*(Boolean)*: Returns `true` if key is a direct property, else `false`.
<!-- /div -->
<!-- div -->
### <a id="Benchmark.indexOf" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L678" title="View in source">`Benchmark.indexOf(array, value)`</a>
### <a id="Benchmark.indexOf" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L750" title="View in source">`Benchmark.indexOf(array, value)`</a>
A generic bare-bones `Array#indexOf` solution.

@@ -351,25 +344,3 @@ [&#9650;][1]

### <a id="Benchmark.interpolate" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L824" title="View in source">`Benchmark.interpolate(string, object)`</a>
Modify a string by replacing named tokens with matching object property values.
[&#9650;][1]
#### Arguments
1. `string` *(String)*: The string to modify.
2. `object` *(Object)*: The template object.
#### Returns
*(String)*: The modified string.
#### Example
Benchmark.interpolate('#{greet} #{who}!', {
'greet': 'Hello',
'who': 'world'
}); // -> 'Hello world!'
<!-- /div -->
<!-- div -->
### <a id="Benchmark.invoke" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L727" title="View in source">`Benchmark.invoke(benches, name [, arg1, arg2, ...])`</a>
### <a id="Benchmark.invoke" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L799" title="View in source">`Benchmark.invoke(benches, name [, arg1, arg2, ...])`</a>
Invokes a method on all items in an array.

@@ -387,29 +358,31 @@ [&#9650;][1]

#### Example
// invoke `reset` on all benchmarks
Benchmark.invoke(benches, 'reset');
~~~ js
// invoke `reset` on all benchmarks
Benchmark.invoke(benches, 'reset');
// invoke `emit` with arguments
Benchmark.invoke(benches, 'emit', 'complete', listener);
// invoke `emit` with arguments
Benchmark.invoke(benches, 'emit', 'complete', listener);
// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks
Benchmark.invoke(benches, {
// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks
Benchmark.invoke(benches, {
// invoke the `run` method
'name': 'run',
// invoke the `run` method
'name': 'run',
// pass a single argument
'args': true,
// pass a single argument
'args': true,
// treat as queue, removing benchmarks from front of `benches` until empty
'queued': true,
// treat as queue, removing benchmarks from front of `benches` until empty
'queued': true,
// called before any benchmarks have been invoked.
'onStart': onStart,
// called before any benchmarks have been invoked.
'onStart': onStart,
// called between invoking benchmarks
'onCycle': onCycle,
// called between invoking benchmarks
'onCycle': onCycle,
// called after all benchmarks have been invoked.
'onComplete': onComplete
});
// called after all benchmarks have been invoked.
'onComplete': onComplete
});
~~~

@@ -421,52 +394,3 @@ <!-- /div -->

### <a id="Benchmark.isArray" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L839" title="View in source">`Benchmark.isArray(value)`</a>
Determines if the given value is an array.
[&#9650;][1]
#### Arguments
1. `value` *(Mixed)*: The value to check.
#### Returns
*(Boolean)*: Returns `true` if value is an array, else `false`.
<!-- /div -->
<!-- div -->
### <a id="Benchmark.isClassOf" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L851" title="View in source">`Benchmark.isClassOf(object, name)`</a>
Checks if an object is of the specified class.
[&#9650;][1]
#### Arguments
1. `object` *(Object)*: The object.
2. `name` *(String)*: The name of the class.
#### Returns
*(Boolean)*: Returns `true` if of the class, else `false`.
<!-- /div -->
<!-- div -->
### <a id="Benchmark.isHostType" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L865" title="View in source">`Benchmark.isHostType(object, property)`</a>
Host objects can return type values that are different from their actual
data type. The objects we are concerned with usually return non-primitive
types of object, function, or unknown.
[&#9650;][1]
#### Arguments
1. `object` *(Mixed)*: The owner of the property.
2. `property` *(String)*: The property to check.
#### Returns
*(Boolean)*: Returns `true` if the property value is a non-primitive, else `false`.
<!-- /div -->
<!-- div -->
### <a id="Benchmark.join" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L879" title="View in source">`Benchmark.join(object [, separator1=',', separator2=': '])`</a>
### <a id="Benchmark.join" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L890" title="View in source">`Benchmark.join(object [, separator1=',', separator2=': '])`</a>
Creates a string of joined array values or object key-value pairs.

@@ -488,3 +412,3 @@ [&#9650;][1]

### <a id="Benchmark.map" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L901" title="View in source">`Benchmark.map(array, callback)`</a>
### <a id="Benchmark.map" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L912" title="View in source">`Benchmark.map(array, callback)`</a>
A generic bare-bones `Array#map` solution.

@@ -505,12 +429,3 @@ [&#9650;][1]

### <a id="Benchmark.noop" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L913" title="View in source">`Benchmark.noop`</a>
A no-operation function.
[&#9650;][1]
<!-- /div -->
<!-- div -->
### <a id="Benchmark.pluck" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L925" title="View in source">`Benchmark.pluck(array, property)`</a>
### <a id="Benchmark.pluck" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L927" title="View in source">`Benchmark.pluck(array, property)`</a>
Retrieves the value of a specified property from all items in an array.

@@ -531,3 +446,3 @@ [&#9650;][1]

### <a id="Benchmark.reduce" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L940" title="View in source">`Benchmark.reduce(array, callback, accumulator)`</a>
### <a id="Benchmark.reduce" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L942" title="View in source">`Benchmark.reduce(array, callback, accumulator)`</a>
A generic bare-bones `Array#reduce` solution.

@@ -547,13 +462,17 @@ [&#9650;][1]

<!-- /div -->
<!-- div -->
### <a id="Benchmark.trim" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L954" title="View in source">`Benchmark.trim(string)`</a>
A generic bare-bones `String#trim` solution.
## `Benchmark.prototype`
### <a id="Benchmark" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L129" title="View in source">`Benchmark(name, fn [, options={}])`</a>
Benchmark constructor.
[&#9650;][1]
#### Arguments
1. `string` *(String)*: The string to trim.
<!-- div -->
#### Returns
*(String)*: The trimmed string.
### <a id="Benchmark:aborted" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1718" title="View in source">`Benchmark#aborted`</a>
*(Boolean)*: A flag to indicate if the benchmark is aborted.
[&#9650;][1]

@@ -563,13 +482,15 @@ <!-- /div -->

<!-- /div -->
<!-- div -->
### <a id="Benchmark:count" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1690" title="View in source">`Benchmark#count`</a>
*(Number)*: The number of times a test was executed.
[&#9650;][1]
<!-- div -->
<!-- /div -->
## `Benchmark.prototype`
<!-- div -->
### <a id="Benchmark:CYCLE_DELAY" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1801" title="View in source">`Benchmark#CYCLE_DELAY`</a>
*(Number)*: The delay between test cycles *(secs)*.
### <a id="Benchmark:cycles" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1697" title="View in source">`Benchmark#cycles`</a>
*(Number)*: The number of cycles performed while benchmarking.
[&#9650;][1]

@@ -582,4 +503,4 @@

### <a id="Benchmark:DEFAULT_ASYNC" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1808" title="View in source">`Benchmark#DEFAULT_ASYNC`</a>
*(Boolean)*: A flag to indicate methods will run asynchronously by default.
### <a id="Benchmark:error" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1704" title="View in source">`Benchmark#error`</a>
*(Object, Null)*: The error object if the test failed.
[&#9650;][1]

@@ -592,4 +513,4 @@

### <a id="Benchmark:INIT_RUN_COUNT" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1815" title="View in source">`Benchmark#INIT_RUN_COUNT`</a>
*(Number)*: The default number of times to execute a test on a benchmark's first cycle.
### <a id="Benchmark:hz" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1711" title="View in source">`Benchmark#hz`</a>
*(Number)*: The number of executions per second.
[&#9650;][1]

@@ -602,4 +523,4 @@

### <a id="Benchmark:MAX_TIME_ELAPSED" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1822" title="View in source">`Benchmark#MAX_TIME_ELAPSED`</a>
*(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*.
### <a id="Benchmark:on" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1731" title="View in source">`Benchmark.Suite#on`</a>
*(Unknown)*: Alias of [`Benchmark#addListener`](#Benchmark:addListener).
[&#9650;][1]

@@ -612,4 +533,4 @@

### <a id="Benchmark:MIN_SAMPLE_SIZE" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1829" title="View in source">`Benchmark#MIN_SAMPLE_SIZE`</a>
*(Number)*: The minimum sample size required to perform statistical analysis.
### <a id="Benchmark:running" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1725" title="View in source">`Benchmark#running`</a>
*(Boolean)*: A flag to indicate if the benchmark is running.
[&#9650;][1]

@@ -622,6 +543,9 @@

### <a id="Benchmark:MIN_TIME" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1836" title="View in source">`Benchmark#MIN_TIME`</a>
*(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*.
### <a id="Benchmark:abort" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1184" title="View in source">`Benchmark#abort`</a>
Aborts the benchmark without recording times.
[&#9650;][1]
#### Returns
*(Object)*: The benchmark instance.
<!-- /div -->

@@ -632,14 +556,21 @@

### <a id="Benchmark:aborted" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1878" title="View in source">`Benchmark#aborted`</a>
*(Boolean)*: A flag to indicate if the benchmark is aborted.
### <a id="Benchmark:addListener" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1094" title="View in source">`Benchmark.Suite#addListener(type, listener)`</a>
Registers a single listener of a specified event type.
[&#9650;][1]
<!-- /div -->
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function called when the event occurs.
#### Returns
*(Object)*: The benchmark instance.
<!-- div -->
#### Example
~~~ js
// basic usage
bench.addListener('cycle', listener);
### <a id="Benchmark:count" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1843" title="View in source">`Benchmark#count`</a>
*(Number)*: The number of times a test was executed.
[&#9650;][1]
// register a listener for multiple event types
bench.addListener('start cycle', listener);
~~~

@@ -651,6 +582,19 @@ <!-- /div -->

### <a id="Benchmark:created" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1850" title="View in source">`Benchmark#created`</a>
*(Number)*: A timestamp of when the benchmark was created.
### <a id="Benchmark:clone" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1212" title="View in source">`Benchmark#clone(options)`</a>
Creates a new benchmark using the same test and options.
[&#9650;][1]
#### Arguments
1. `options` *(Object)*: Options object to overwrite cloned options.
#### Returns
*(Object)*: The new benchmark instance.
#### Example
~~~ js
var bizarro = bench.clone({
'name': 'doppelganger'
});
~~~
<!-- /div -->

@@ -661,6 +605,12 @@

### <a id="Benchmark:cycles" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1857" title="View in source">`Benchmark#cycles`</a>
*(Number)*: The number of cycles performed while benchmarking.
### <a id="Benchmark:compare" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1230" title="View in source">`Benchmark#compare(other)`</a>
Determines if the benchmark's period is smaller than another.
[&#9650;][1]
#### Arguments
1. `other` *(Object)*: The benchmark to compare.
#### Returns
*(Number)*: Returns `1` if smaller, `-1` if larger, and `0` if indeterminate.
<!-- /div -->

@@ -671,6 +621,12 @@

### <a id="Benchmark:error" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1864" title="View in source">`Benchmark#error`</a>
*(Object|Null)*: The error object if the test failed.
### <a id="Benchmark:emit" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1110" title="View in source">`Benchmark.Suite#emit(type)`</a>
Executes all registered listeners of a specified event type.
[&#9650;][1]
#### Arguments
1. `type` *(String|Object)*: The event type or object.
#### Returns
*(Boolean)*: Returns `true` if all listeners were executed, else `false`.
<!-- /div -->

@@ -681,6 +637,21 @@

### <a id="Benchmark:hz" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1871" title="View in source">`Benchmark#hz`</a>
*(Number)*: The number of executions per second.
### <a id="Benchmark:removeAllListeners" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1167" title="View in source">`Benchmark.Suite#removeAllListeners(type)`</a>
Unregisters all listeners of a specified event type.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// basic usage
bench.removeAllListeners('cycle');
// unregister all listeners for multiple event types
bench.removeListener('start cycle');
~~~
<!-- /div -->

@@ -691,6 +662,22 @@

### <a id="Benchmark:running" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1885" title="View in source">`Benchmark#running`</a>
*(Boolean)*: A flag to indicate if the benchmark is running.
### <a id="Benchmark:removeListener" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1140" title="View in source">`Benchmark.Suite#removeListener(type, listener)`</a>
Unregisters a single listener of a specified event type.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function to unregister.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// basic usage
bench.removeListener('cycle', listener);
// unregister a listener for multiple event types
bench.removeListener('start cycle', listener);
~~~
<!-- /div -->

@@ -701,4 +688,4 @@

### <a id="Benchmark:abort" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1192" title="View in source">`Benchmark#abort`</a>
Aborts the benchmark without recording times.
### <a id="Benchmark:reset" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1250" title="View in source">`Benchmark#reset`</a>
Reset properties and abort if running.
[&#9650;][1]

@@ -714,9 +701,8 @@

### <a id="Benchmark:addListener" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1103" title="View in source">`Benchmark#addListener(type, listener)`</a>
Registers a single listener of a specified event type.
### <a id="Benchmark:run" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1434" title="View in source">`Benchmark#run([async=false])`</a>
Runs the benchmark.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function called when the event occurs.
1. `[async=false]` *(Boolean)*: Flag to run asynchronously.

@@ -726,8 +712,31 @@ #### Returns

<!-- /div -->
<!-- div -->
### <a id="Benchmark:setup" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1757" title="View in source">`Benchmark#setup`</a>
Compiled into the test and executed immediately **before** the test loop.
[&#9650;][1]
#### Example
// basic usage
bench.addListener('cycle', listener);
~~~ js
var bench = new Benchmark({
'fn': function() {
a += 1;
},
'setup': function() {
// reset local var `a` at the beginning of each test cycle
a = 0;
}
});
// register a listener for multiple event types
bench.addListener('start cycle', listener);
// compiles into something like:
var a = 0;
var start = new Date;
while (count--) {
a += 1;
}
var end = new Date - start;
~~~

@@ -739,17 +748,21 @@ <!-- /div -->

### <a id="Benchmark:clone" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1220" title="View in source">`Benchmark#clone(options)`</a>
Creates a new benchmark using the same test and options.
### <a id="Benchmark:teardown" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1764" title="View in source">`Benchmark#teardown`</a>
Compiled into the test and executed immediately **after** the test loop.
[&#9650;][1]
#### Arguments
1. `options` *(Object)*: Options object to overwrite cloned options.
<!-- /div -->
<!-- div -->
### <a id="Benchmark:toString" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1290" title="View in source">`Benchmark#toString`</a>
Displays relevant benchmark information when coerced to a string.
[&#9650;][1]
#### Returns
*(Object)*: The new benchmark instance.
*(String)*: A string representation of the benchmark instance.
#### Example
var bizarro = bench.clone({
'name': 'doppelganger'
});
<!-- /div -->
<!-- /div -->

@@ -760,11 +773,9 @@

### <a id="Benchmark:compare" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1238" title="View in source">`Benchmark#compare(other)`</a>
Determines if the benchmark's period is smaller than another.
[&#9650;][1]
## `options`
#### Arguments
1. `other` *(Object)*: The benchmark to compare.
<!-- div -->
#### Returns
*(Number)*: Returns `1` if smaller, `-1` if larger, and `0` if indeterminate.
### <a id="Benchmark.options" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1544" title="View in source">`options`</a>
*(Object)*: The default options object copied by instances.
[&#9650;][1]

@@ -776,9 +787,13 @@ <!-- /div -->

### <a id="Benchmark:emit" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1118" title="View in source">`Benchmark#emit(type)`</a>
Executes all registered listeners of a specified event type.
## `options`
### <a id="Benchmark.options" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1544" title="View in source">`options`</a>
*(Object)*: The default options object copied by instances.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
<!-- div -->
### <a id="Benchmark.options.async" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1551" title="View in source">`Benchmark.options.async`</a>
*(Boolean)*: A flag to indicate methods will run asynchronously by default.
[&#9650;][1]
<!-- /div -->

@@ -789,4 +804,4 @@

### <a id="Benchmark:on" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1891" title="View in source">`Benchmark#on`</a>
Alias of [`Benchmark#addListener`](#Benchmark:addListener).
### <a id="Benchmark.options.delay" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1558" title="View in source">`Benchmark.options.delay`</a>
*(Number)*: The delay between test cycles *(secs)*.
[&#9650;][1]

@@ -799,18 +814,14 @@

### <a id="Benchmark:removeAllListeners" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1175" title="View in source">`Benchmark#removeAllListeners(type)`</a>
Unregisters all listeners of a specified event type.
### <a id="Benchmark.options.initCount" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1565" title="View in source">`Benchmark.options.initCount`</a>
*(Number)*: The default number of times to execute a test on a benchmark's first cycle.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
<!-- /div -->
#### Returns
*(Object)*: The benchmark instance.
#### Example
// basic usage
bench.removeAllListeners('cycle');
<!-- div -->
// unregister all listeners for multiple event types
bench.removeListener('start cycle');
### <a id="Benchmark.options.maxTime" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1572" title="View in source">`Benchmark.options.maxTime`</a>
*(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*.
[&#9650;][1]

@@ -822,19 +833,14 @@ <!-- /div -->

### <a id="Benchmark:removeListener" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1148" title="View in source">`Benchmark#removeListener(type, listener)`</a>
Unregisters a single listener of a specified event type.
### <a id="Benchmark.options.minSamples" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1579" title="View in source">`Benchmark.options.minSamples`</a>
*(Number)*: The minimum sample size required to perform statistical analysis.
[&#9650;][1]
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function to unregister.
<!-- /div -->
#### Returns
*(Object)*: The benchmark instance.
#### Example
// basic usage
bench.removeListener('cycle', listener);
<!-- div -->
// unregister a listener for multiple event types
bench.removeListener('start cycle', listener);
### <a id="Benchmark.options.minTime" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1586" title="View in source">`Benchmark.options.minTime`</a>
*(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*.
[&#9650;][1]

@@ -844,11 +850,31 @@ <!-- /div -->

<!-- /div -->
<!-- div -->
### <a id="Benchmark:reset" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1258" title="View in source">`Benchmark#reset`</a>
Reset properties and abort if running.
## `platform`
<!-- div -->
### <a id="Benchmark.platform" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1595" title="View in source">`platform`</a>
*(Object)*: Platform object containing browser name, version, and operating system.
[&#9650;][1]
#### Returns
*(Object)*: The benchmark instance.
<!-- /div -->
<!-- div -->
## `platform`
### <a id="Benchmark.platform" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1595" title="View in source">`platform`</a>
*(Object)*: Platform object containing browser name, version, and operating system.
[&#9650;][1]
<!-- div -->
### <a id="Benchmark.platform.description" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1602" title="View in source">`Benchmark.platform.description`</a>
*(String)*: The platform description.
[&#9650;][1]
<!-- /div -->

@@ -859,12 +885,15 @@

### <a id="Benchmark:run" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1442" title="View in source">`Benchmark#run([async=false])`</a>
Runs the benchmark.
### <a id="Benchmark.platform.layout" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1609" title="View in source">`Benchmark.platform.layout`</a>
*(String, Null)*: The name of the browser layout engine.
[&#9650;][1]
#### Arguments
1. `[async=false]` *(Boolean)*: Flag to run asynchronously.
<!-- /div -->
#### Returns
*(Object)*: The benchmark instance.
<!-- div -->
### <a id="Benchmark.platform.name" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1623" title="View in source">`Benchmark.platform.name`</a>
*(String, Null)*: The name of the browser/environment.
[&#9650;][1]
<!-- /div -->

@@ -875,25 +904,15 @@

### <a id="Benchmark:setup" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1917" title="View in source">`Benchmark#setup`</a>
Compiled into the test and executed immediately **before** the test loop.
### <a id="Benchmark.platform.os" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1630" title="View in source">`Benchmark.platform.os`</a>
*(String, Null)*: The name of the operating system.
[&#9650;][1]
#### Example
var bench = new Benchmark({
'fn': function() {
a += 1;
},
'setup': function() {
// reset local var `a` at the beginning of each test cycle
a = 0;
}
});
<!-- /div -->
// compiles into something like:
var a = 0;
var start = new Date;
while (count--) {
a += 1;
}
var end = new Date - start;
<!-- div -->
### <a id="Benchmark.platform.product" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1616" title="View in source">`Benchmark.platform.product`</a>
*(String, Null)*: The name of the product hosting the browser.
[&#9650;][1]
<!-- /div -->

@@ -904,4 +923,4 @@

### <a id="Benchmark:teardown" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1924" title="View in source">`Benchmark#teardown`</a>
Compiled into the test and executed immediately **after** the test loop.
### <a id="Benchmark.platform.version" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1637" title="View in source">`Benchmark.platform.version`</a>
*(String, Null)*: The browser/environment version.
[&#9650;][1]

@@ -914,8 +933,8 @@

### <a id="Benchmark:toString" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1299" title="View in source">`Benchmark#toString`</a>
Displays relevant benchmark information when coerced to a string.
### <a id="Benchmark.platform.toString" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1645" title="View in source">`Benchmark.platform.toString`</a>
Return platform description when the platform object is coerced to a string.
[&#9650;][1]
#### Returns
*(String)*: A string representation of the benchmark instance.
*(String)*: The platform description.

@@ -925,5 +944,12 @@ <!-- /div -->

<!-- /div -->
<!-- div -->
### <a id="Benchmark:stats" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1931" title="View in source">`Benchmark#stats`</a>
## `stats`
<!-- div -->
### <a id="Benchmark:stats" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1771" title="View in source">`stats`</a>
*(Object)*: An object of stats including mean, margin or error, and standard deviation.

@@ -937,6 +963,13 @@ [&#9650;][1]

### <a id="Benchmark:stats.ME" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1938" title="View in source">`Benchmark#stats.ME`</a>
*(Number)*: The margin of error.
## `stats`
### <a id="Benchmark:stats" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1771" title="View in source">`stats`</a>
*(Object)*: An object of stats including mean, margin or error, and standard deviation.
[&#9650;][1]
<!-- div -->
### <a id="Benchmark:stats.deviation" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1799" title="View in source">`Benchmark#stats.deviation`</a>
*(Number)*: The sample standard deviation.
[&#9650;][1]
<!-- /div -->

@@ -947,4 +980,4 @@

### <a id="Benchmark:stats.RME" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1945" title="View in source">`Benchmark#stats.RME`</a>
*(Number)*: The relative margin of error *(expressed as a percentage of the mean)*.
### <a id="Benchmark:stats.mean" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1806" title="View in source">`Benchmark#stats.mean`</a>
*(Number)*: The sample arithmetic mean.
[&#9650;][1]

@@ -957,4 +990,4 @@

### <a id="Benchmark:stats.SEM" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1952" title="View in source">`Benchmark#stats.SEM`</a>
*(Number)*: The standard error of the mean.
### <a id="Benchmark:stats.moe" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1778" title="View in source">`Benchmark#stats.moe`</a>
*(Number)*: The margin of error.
[&#9650;][1]

@@ -967,4 +1000,4 @@

### <a id="Benchmark:stats.deviation" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1959" title="View in source">`Benchmark#stats.deviation`</a>
*(Number)*: The sample standard deviation.
### <a id="Benchmark:stats.rme" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1785" title="View in source">`Benchmark#stats.rme`</a>
*(Number)*: The relative margin of error *(expressed as a percentage of the mean)*.
[&#9650;][1]

@@ -977,4 +1010,4 @@

### <a id="Benchmark:stats.mean" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1966" title="View in source">`Benchmark#stats.mean`</a>
*(Number)*: The sample arithmetic mean.
### <a id="Benchmark:stats.sem" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1792" title="View in source">`Benchmark#stats.sem`</a>
*(Number)*: The standard error of the mean.
[&#9650;][1]

@@ -987,3 +1020,3 @@

### <a id="Benchmark:stats.size" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1973" title="View in source">`Benchmark#stats.size`</a>
### <a id="Benchmark:stats.size" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1813" title="View in source">`Benchmark#stats.size`</a>
*(Number)*: The sample size.

@@ -997,3 +1030,3 @@ [&#9650;][1]

### <a id="Benchmark:stats.variance" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1980" title="View in source">`Benchmark#stats.variance`</a>
### <a id="Benchmark:stats.variance" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1820" title="View in source">`Benchmark#stats.variance`</a>
*(Number)*: The sample variance.

@@ -1005,5 +1038,12 @@ [&#9650;][1]

<!-- /div -->
<!-- div -->
### <a id="Benchmark:times" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1988" title="View in source">`Benchmark#times`</a>
## `times`
<!-- div -->
### <a id="Benchmark:times" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1828" title="View in source">`times`</a>
*(Object)*: An object of timing data including cycle, elapsed, period, start, and stop.

@@ -1017,3 +1057,10 @@ [&#9650;][1]

### <a id="Benchmark:times.cycle" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1995" title="View in source">`Benchmark#times.cycle`</a>
## `times`
### <a id="Benchmark:times" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1828" title="View in source">`times`</a>
*(Object)*: An object of timing data including cycle, elapsed, period, start, and stop.
[&#9650;][1]
<!-- div -->
### <a id="Benchmark:times.cycle" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1835" title="View in source">`Benchmark#times.cycle`</a>
*(Number)*: The time taken to complete the last cycle *(secs)*

@@ -1027,3 +1074,3 @@ [&#9650;][1]

### <a id="Benchmark:times.elapsed" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2002" title="View in source">`Benchmark#times.elapsed`</a>
### <a id="Benchmark:times.elapsed" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1842" title="View in source">`Benchmark#times.elapsed`</a>
*(Number)*: The time taken to complete the benchmark *(secs)*.

@@ -1037,3 +1084,3 @@ [&#9650;][1]

### <a id="Benchmark:times.period" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2009" title="View in source">`Benchmark#times.period`</a>
### <a id="Benchmark:times.period" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1849" title="View in source">`Benchmark#times.period`</a>
*(Number)*: The time taken to execute the test once *(secs)*.

@@ -1047,3 +1094,3 @@ [&#9650;][1]

### <a id="Benchmark:times.start" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2016" title="View in source">`Benchmark#times.start`</a>
### <a id="Benchmark:times.start" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1856" title="View in source">`Benchmark#times.start`</a>
*(Number)*: A timestamp of when the benchmark started *(ms)*.

@@ -1057,3 +1104,3 @@ [&#9650;][1]

### <a id="Benchmark:times.stop" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2023" title="View in source">`Benchmark#times.stop`</a>
### <a id="Benchmark:times.stop" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1863" title="View in source">`Benchmark#times.stop`</a>
*(Number)*: A timestamp of when the benchmark finished *(ms)*.

@@ -1070,7 +1117,7 @@ [&#9650;][1]

## `Benchmark.Suite`
## `Suite`
<!-- div -->
### <a id="Benchmark.Suite" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L194" title="View in source">`Benchmark.Suite(name [, options={}])`</a>
### <a id="Benchmark.Suite" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L193" title="View in source">`Suite(name [, options={}])`</a>
Suite constructor.

@@ -1084,29 +1131,31 @@ [&#9650;][1]

#### Example
// basic usage
var suite = new Benchmark.Suite;
~~~ js
// basic usage
var suite = new Benchmark.Suite;
// or using a name first
var suite = new Benchmark.Suite('foo');
// or using a name first
var suite = new Benchmark.Suite('foo');
// or with options
var suite = new Benchmark.Suite('foo', {
// or with options
var suite = new Benchmark.Suite('foo', {
// called when the suite starts running
'onStart': onStart,
// called when the suite starts running
'onStart': onStart,
// called between running benchmarks
'onCycle': onCycle,
// called between running benchmarks
'onCycle': onCycle,
// called when aborted
'onAbort': onAbort,
// called when aborted
'onAbort': onAbort,
// called when a test errors
'onError': onError,
// called when a test errors
'onError': onError,
// called when reset
'onReset': onReset,
// called when reset
'onReset': onReset,
// called when the suite completes running
'onComplete': onComplete
});
// called when the suite completes running
'onComplete': onComplete
});
~~~

@@ -1116,10 +1165,17 @@ <!-- /div -->

<!-- /div -->
<!-- div -->
### <a id="Benchmark.Suite.options" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2062" title="View in source">`Benchmark.Suite.options`</a>
*(Object)*: The default options object copied by instances.
## `Suite.prototype`
### <a id="Benchmark.Suite" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L193" title="View in source">`Suite(name [, options={}])`</a>
Suite constructor.
[&#9650;][1]
<!-- /div -->
<!-- div -->
### <a id="Benchmark.Suite:aborted" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1920" title="View in source">`Benchmark.Suite#aborted`</a>
*(Boolean)*: A flag to indicate if the suite is aborted.
[&#9650;][1]

@@ -1131,8 +1187,4 @@ <!-- /div -->

## `Benchmark.Suite.prototype`
<!-- div -->
### <a id="Benchmark.Suite:aborted" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2080" title="View in source">`Benchmark.Suite#aborted`</a>
*(Boolean)*: A flag to indicate if the suite is aborted.
### <a id="Benchmark.Suite:length" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1913" title="View in source">`Benchmark.Suite#length`</a>
*(Number)*: The number of benchmarks in the suite.
[&#9650;][1]

@@ -1145,4 +1197,4 @@

### <a id="Benchmark.Suite:length" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2073" title="View in source">`Benchmark.Suite#length`</a>
*(Number)*: The number of benchmarks in the suite.
### <a id="Benchmark:on" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1731" title="View in source">`Benchmark.Suite#on`</a>
*(Unknown)*: Alias of [`Benchmark#addListener`](#Benchmark:addListener).
[&#9650;][1]

@@ -1155,3 +1207,3 @@

### <a id="Benchmark.Suite:running" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2087" title="View in source">`Benchmark.Suite#running`</a>
### <a id="Benchmark.Suite:running" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1927" title="View in source">`Benchmark.Suite#running`</a>
*(Boolean)*: A flag to indicate if the suite is running.

@@ -1165,3 +1217,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:abort" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L966" title="View in source">`Benchmark.Suite#abortSuite`</a>
### <a id="Benchmark.Suite:abort" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L957" title="View in source">`Benchmark.Suite#abortSuite`</a>
Aborts all benchmarks in the suite.

@@ -1178,3 +1230,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:add" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L996" title="View in source">`Benchmark.Suite#add(name, fn [, options={}])`</a>
### <a id="Benchmark.Suite:add" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L987" title="View in source">`Benchmark.Suite#add(name, fn [, options={}])`</a>
Adds a test to the benchmark suite.

@@ -1192,13 +1244,15 @@ [&#9650;][1]

#### Example
// basic usage
suite.add(fn);
~~~ js
// basic usage
suite.add(fn);
// or using a name first
suite.add('foo', fn);
// or using a name first
suite.add('foo', fn);
// or with options
suite.add('foo', fn, {
'onCycle': onCycle,
'onComplete': onComplete
});
// or with options
suite.add('foo', fn, {
'onCycle': onCycle,
'onComplete': onComplete
});
~~~

@@ -1210,3 +1264,3 @@ <!-- /div -->

### <a id="Benchmark.Suite:addListener" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1103" title="View in source">`Benchmark.Suite#addListener(type, listener)`</a>
### <a id="Benchmark:addListener" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1094" title="View in source">`Benchmark.Suite#addListener(type, listener)`</a>
Registers a single listener of a specified event type.

@@ -1223,7 +1277,9 @@ [&#9650;][1]

#### Example
// basic usage
bench.addListener('cycle', listener);
~~~ js
// basic usage
bench.addListener('cycle', listener);
// register a listener for multiple event types
bench.addListener('start cycle', listener);
// register a listener for multiple event types
bench.addListener('start cycle', listener);
~~~

@@ -1235,3 +1291,3 @@ <!-- /div -->

### <a id="Benchmark.Suite:clone" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1013" title="View in source">`Benchmark.Suite#cloneSuite(options)`</a>
### <a id="Benchmark.Suite:clone" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1004" title="View in source">`Benchmark.Suite#cloneSuite(options)`</a>
Creates a new suite with cloned benchmarks.

@@ -1251,5 +1307,4 @@ [&#9650;][1]

### <a id="Benchmark.Suite:each" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2096" title="View in source">`Benchmark.Suite#each(callback)`</a>
### <a id="Benchmark.Suite:each" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1936" title="View in source">`Benchmark.Suite#each(callback)`</a>
A bare-bones `Array#forEach` solution.
Callbacks may terminate the loop by explicitly returning `false`.
[&#9650;][1]

@@ -1268,3 +1323,3 @@

### <a id="Benchmark.Suite:emit" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1118" title="View in source">`Benchmark.Suite#emit(type)`</a>
### <a id="Benchmark:emit" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1110" title="View in source">`Benchmark.Suite#emit(type)`</a>
Executes all registered listeners of a specified event type.

@@ -1274,4 +1329,7 @@ [&#9650;][1]

#### Arguments
1. `type` *(String)*: The event type.
1. `type` *(String|Object)*: The event type or object.
#### Returns
*(Boolean)*: Returns `true` if all listeners were executed, else `false`.
<!-- /div -->

@@ -1282,3 +1340,3 @@

### <a id="Benchmark.Suite:filter" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1032" title="View in source">`Benchmark.Suite#filterSuite(callback)`</a>
### <a id="Benchmark.Suite:filter" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1023" title="View in source">`Benchmark.Suite#filterSuite(callback)`</a>
A bare-bones `Array#filter` solution.

@@ -1298,3 +1356,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:indexOf" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2104" title="View in source">`Benchmark.Suite#indexOf(value)`</a>
### <a id="Benchmark.Suite:indexOf" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1944" title="View in source">`Benchmark.Suite#indexOf(value)`</a>
A bare-bones `Array#indexOf` solution.

@@ -1314,3 +1372,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:invoke" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2113" title="View in source">`Benchmark.Suite#invoke(name [, arg1, arg2, ...])`</a>
### <a id="Benchmark.Suite:invoke" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1953" title="View in source">`Benchmark.Suite#invoke(name [, arg1, arg2, ...])`</a>
Invokes a method on all benchmarks in the suite.

@@ -1331,3 +1389,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:map" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2121" title="View in source">`Benchmark.Suite#map(callback)`</a>
### <a id="Benchmark.Suite:map" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1961" title="View in source">`Benchmark.Suite#map(callback)`</a>
A bare-bones `Array#map` solution.

@@ -1347,12 +1405,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:on" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1891" title="View in source">`Benchmark.Suite#on`</a>
Alias of [`Benchmark#addListener`](#Benchmark:addListener).
[&#9650;][1]
<!-- /div -->
<!-- div -->
### <a id="Benchmark.Suite:pluck" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2129" title="View in source">`Benchmark.Suite#pluck(property)`</a>
### <a id="Benchmark.Suite:pluck" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1969" title="View in source">`Benchmark.Suite#pluck(property)`</a>
Retrieves the value of a specified property from all benchmarks in the suite.

@@ -1372,3 +1421,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:reduce" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L2138" title="View in source">`Benchmark.Suite#reduce(callback, accumulator)`</a>
### <a id="Benchmark.Suite:reduce" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1978" title="View in source">`Benchmark.Suite#reduce(callback, accumulator)`</a>
A bare-bones `Array#reduce` solution.

@@ -1389,3 +1438,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:removeAllListeners" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1175" title="View in source">`Benchmark.Suite#removeAllListeners(type)`</a>
### <a id="Benchmark:removeAllListeners" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1167" title="View in source">`Benchmark.Suite#removeAllListeners(type)`</a>
Unregisters all listeners of a specified event type.

@@ -1401,7 +1450,9 @@ [&#9650;][1]

#### Example
// basic usage
bench.removeAllListeners('cycle');
~~~ js
// basic usage
bench.removeAllListeners('cycle');
// unregister all listeners for multiple event types
bench.removeListener('start cycle');
// unregister all listeners for multiple event types
bench.removeListener('start cycle');
~~~

@@ -1413,3 +1464,3 @@ <!-- /div -->

### <a id="Benchmark.Suite:removeListener" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1148" title="View in source">`Benchmark.Suite#removeListener(type, listener)`</a>
### <a id="Benchmark:removeListener" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1140" title="View in source">`Benchmark.Suite#removeListener(type, listener)`</a>
Unregisters a single listener of a specified event type.

@@ -1426,7 +1477,9 @@ [&#9650;][1]

#### Example
// basic usage
bench.removeListener('cycle', listener);
~~~ js
// basic usage
bench.removeListener('cycle', listener);
// unregister a listener for multiple event types
bench.removeListener('start cycle', listener);
// unregister a listener for multiple event types
bench.removeListener('start cycle', listener);
~~~

@@ -1438,3 +1491,3 @@ <!-- /div -->

### <a id="Benchmark.Suite:reset" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1046" title="View in source">`Benchmark.Suite#resetSuite`</a>
### <a id="Benchmark.Suite:reset" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1037" title="View in source">`Benchmark.Suite#resetSuite`</a>
Resets all benchmarks in the suite.

@@ -1451,3 +1504,3 @@ [&#9650;][1]

### <a id="Benchmark.Suite:run" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L1062" title="View in source">`Benchmark.Suite#runSuite([async=false, queued=false])`</a>
### <a id="Benchmark.Suite:run" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1053" title="View in source">`Benchmark.Suite#runSuite([async=false, queued=false])`</a>
Runs the suite.

@@ -1469,5 +1522,21 @@ [&#9650;][1]

<!-- div -->
## `options`
<!-- div -->
### <a id="Benchmark.Suite.options" href="https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1902" title="View in source">`options`</a>
*(Object)*: The default options object copied by instances.
[&#9650;][1]
<!-- /div -->
<!-- /div -->
<!-- /div -->
[1]: #readme "Jump back to the TOC."
{
"name": "benchmark",
"version": "0.2.1",
"version": "0.2.2",
"description": "A benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results.",

@@ -40,7 +40,7 @@ "homepage": "http://benchmarkjs.com/",

"email": "bugs@benchmarkjs.com",
"url": "https://github.com/mathiasbynens/Benchmark.js/issues"
"url": "https://github.com/bestiejs/benchmark.js/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/mathiasbynens/Benchmark.js.git"
"url": "https://github.com/bestiejs/benchmark.js.git"
},

@@ -47,0 +47,0 @@ "engines": [

# Benchmark.js
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
## BestieJS
Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
## Documentation

@@ -9,3 +13,3 @@

For a list of upcoming features, check out our [roadmap](https://github.com/mathiasbynens/benchmark.js/wiki/Roadmap).
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).

@@ -16,11 +20,11 @@ ## Installation and usage

``` html
~~~ html
<script src="benchmark.js"></script>
```
~~~
Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the `<body>`:
``` html
~~~ html
<applet code="nano" archive="nano.jar"></applet>
```
~~~

@@ -33,33 +37,50 @@ Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking):

``` bash
~~~ bash
npm install benchmark
```
~~~
In [Node.js](http://nodejs.org/):
``` js
~~~ js
var Benchmark = require('benchmark');
```
~~~
Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons:
``` bash
~~~ bash
npm install microtime
```
~~~
In [Narwhal](http://narwhaljs.org/) and [RingoJS](http://ringojs.org/):
``` js
~~~ js
var Benchmark = require('benchmark').Benchmark;
```
~~~
In [Rhino](http://www.mozilla.org/rhino/):
``` js
~~~ js
load('benchmark.js');
```
~~~
In [RequireJS](http://requirejs.org/):
~~~ js
require(['path/to/benchmark'], function(Benchmark) {
console.log(Benchmark.version);
});
// auto-require platform.js
// https://github.com/bestiejs/platform.js
require({
'paths': { 'platform': 'path/to/platform' }
},
['path/to/benchmark'], function(Benchmark) {
console.log(Benchmark.platform.name);
});
~~~
Usage example:
``` js
~~~ js
var suite = new Benchmark.Suite;

@@ -75,3 +96,3 @@

// add listeners
.on('cycle', function(bench) {
.on('cycle', function(event, bench) {
console.log(String(bench));

@@ -89,3 +110,3 @@ })

// > Fastest is String#indexOf
```
~~~

@@ -96,17 +117,22 @@ ## Cloning this repo

``` bash
git clone --recursive https://github.com/mathiasbynens/Benchmark.js.git
cd Benchmark.js
```
~~~ bash
git clone --recursive https://github.com/bestiejs/benchmark.js.git
cd benchmark.js
~~~
For older git versions, just use:
``` bash
git clone https://github.com/mathiasbynens/Benchmark.js.git
cd Benchmark.js
~~~ bash
git clone https://github.com/bestiejs/benchmark.js.git
cd benchmark.js
git submodule update --init
```
~~~
Feel free to fork if you see possible improvements!
## Footnotes
1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 4/8/13, Firefox 2-4, IE 6-10, Opera 9.25-11, Safari 2-5, Node.js 0.4.1, Narwhal 0.3.2, Ringo 0.6, and Rhino 1.7RC2.
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">&#8617;</a>
## Authors

@@ -113,0 +139,0 @@

(function() {
// load Benchmark
var Benchmark = require('../benchmark.js');
// check Benchmark.platform
console.log('Benchmark.platform: expected at least "Node.js"; got "' +
Benchmark.platform + '";');
(function() {

@@ -15,7 +10,8 @@ global.arr = new Array(100);

// check Benchmark.platform
console.log('Benchmark.platform: expected at least "Node.js"; got "' + Benchmark.platform + '";');
// check synchronous run
bench.on('complete', function() {
console.log('Test sync: expected sync; got ' +
(counter ? 'a' : '') + 'sync ' + bench);
console.log('Test sync: expected sync; got ' + (counter ? 'a' : '') + 'sync ' + bench);
bench.removeAllListeners('complete');

@@ -25,8 +21,4 @@

bench.on('complete', function() {
console.log('Test async: expected async; got ' +
(counter ? 'a' : '') + 'sync ' + bench);
// check Benchmark#MIN_TIME
console.log('Benchmark#MIN_TIME: expected at most 0.05; got ' +
Benchmark.prototype.MIN_TIME + ';');
console.log('Test async: expected async; got ' + (counter ? 'a' : '') + 'sync ' + bench);
console.log('Min time: expected at most 0.05; got ' + Benchmark.options.minTime + ';');
});

@@ -41,4 +33,4 @@

counter++;
})();
}());
}());
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc