# Benchmark.js v1.0.0
## `Benchmark`
* [`Benchmark`](#benchmarkname-fn--options)
* [`Benchmark.version`](#benchmarkversion)
* [`Benchmark.deepClone`](#benchmarkdeepclonevalue)
* [`Benchmark.each`](#benchmarkeachobject-callback-thisarg)
* [`Benchmark.extend`](#benchmarkextenddestination--source)
* [`Benchmark.filter`](#benchmarkfilterarray-callback-thisarg)
* [`Benchmark.forEach`](#benchmarkforeacharray-callback-thisarg)
* [`Benchmark.formatNumber`](#benchmarkformatnumbernumber)
* [`Benchmark.forOwn`](#benchmarkforownobject-callback-thisarg)
* [`Benchmark.hasKey`](#benchmarkhaskeyobject-key)
* [`Benchmark.indexOf`](#benchmarkindexofarray-value--fromindex0)
* [`Benchmark.interpolate`](#benchmarkinterpolatestring-object)
* [`Benchmark.invoke`](#benchmarkinvokebenches-name--arg1-arg2-)
* [`Benchmark.join`](#benchmarkjoinobject--separator1--separator2:)
* [`Benchmark.map`](#benchmarkmaparray-callback-thisarg)
* [`Benchmark.pluck`](#benchmarkpluckarray-property)
* [`Benchmark.reduce`](#benchmarkreducearray-callback-accumulator)
## `Benchmark.prototype`
* [`Benchmark.prototype.aborted`](#benchmarkprototypeaborted)
* [`Benchmark.prototype.compiled`](#benchmarkprototypecompiled)
* [`Benchmark.prototype.count`](#benchmarkprototypecount)
* [`Benchmark.prototype.cycles`](#benchmarkprototypecycles)
* [`Benchmark.prototype.fn`](#benchmarkprototypefn)
* [`Benchmark.prototype.hz`](#benchmarkprototypehz)
* [`Benchmark.prototype.running`](#benchmarkprototyperunning)
* [`Benchmark.prototype.setup`](#benchmarkprototypesetup)
* [`Benchmark.prototype.teardown`](#benchmarkprototypeteardown)
* [`Benchmark.prototype.abort`](#benchmarkprototypeabort)
* [`Benchmark.prototype.clone`](#benchmarkprototypecloneoptions)
* [`Benchmark.prototype.compare`](#benchmarkprototypecompareother)
* [`Benchmark.prototype.emit`](#benchmarkprototypeemittype)
* [`Benchmark.prototype.listeners`](#benchmarkprototypelistenerstype)
* [`Benchmark.prototype.off`](#benchmarkprototypeofftype-listener)
* [`Benchmark.prototype.on`](#benchmarkprototypeontype-listener)
* [`Benchmark.prototype.reset`](#benchmarkprototypereset)
* [`Benchmark.prototype.run`](#benchmarkprototyperunoptions)
* [`Benchmark.prototype.toString`](#benchmarkprototypetostring)
## `Benchmark.options`
* [`Benchmark.options`](#benchmarkoptions)
* [`Benchmark.options.async`](#benchmarkoptionsasync)
* [`Benchmark.options.defer`](#benchmarkoptionsdefer)
* [`Benchmark.options.delay`](#benchmarkoptionsdelay)
* [`Benchmark.options.id`](#benchmarkoptionsid)
* [`Benchmark.options.initCount`](#benchmarkoptionsinitcount)
* [`Benchmark.options.maxTime`](#benchmarkoptionsmaxtime)
* [`Benchmark.options.minSamples`](#benchmarkoptionsminsamples)
* [`Benchmark.options.minTime`](#benchmarkoptionsmintime)
* [`Benchmark.options.name`](#benchmarkoptionsname)
* [`Benchmark.options.onAbort`](#benchmarkoptionsonabort)
* [`Benchmark.options.onComplete`](#benchmarkoptionsoncomplete)
* [`Benchmark.options.onCycle`](#benchmarkoptionsoncycle)
* [`Benchmark.options.onError`](#benchmarkoptionsonerror)
* [`Benchmark.options.onReset`](#benchmarkoptionsonreset)
* [`Benchmark.options.onStart`](#benchmarkoptionsonstart)
## `Benchmark.platform`
* [`Benchmark.platform`](#benchmarkplatform)
* [`Benchmark.platform.description`](#benchmarkplatformdescription)
* [`Benchmark.platform.layout`](#benchmarkplatformlayout)
* [`Benchmark.platform.manufacturer`](#benchmarkplatformmanufacturer)
* [`Benchmark.platform.name`](#benchmarkplatformname)
* [`Benchmark.platform.os`](#benchmarkplatformos)
* [`Benchmark.platform.prerelease`](#benchmarkplatformprerelease)
* [`Benchmark.platform.product`](#benchmarkplatformproduct)
* [`Benchmark.platform.version`](#benchmarkplatformversion)
* [`Benchmark.platform.toString`](#benchmarkplatformtostring)
## `Benchmark.support`
* [`Benchmark.support`](#benchmarksupport)
* [`Benchmark.support.air`](#benchmarksupportair)
* [`Benchmark.support.argumentsClass`](#benchmarksupportargumentsclass)
* [`Benchmark.support.browser`](#benchmarksupportbrowser)
* [`Benchmark.support.charByIndex`](#benchmarksupportcharbyindex)
* [`Benchmark.support.charByOwnIndex`](#benchmarksupportcharbyownindex)
* [`Benchmark.support.decompilation`](#benchmarksupportdecompilation)
* [`Benchmark.support.descriptors`](#benchmarksupportdescriptors)
* [`Benchmark.support.getAllKeys`](#benchmarksupportgetallkeys)
* [`Benchmark.support.iteratesOwnLast`](#benchmarksupportiteratesownfirst)
* [`Benchmark.support.java`](#benchmarksupportjava)
* [`Benchmark.support.nodeClass`](#benchmarksupportnodeclass)
* [`Benchmark.support.timeout`](#benchmarksupporttimeout)
## `Benchmark.prototype.error`
* [`Benchmark.prototype.error`](#benchmarkprototypeerror)
## `Benchmark.prototype.stats`
* [`Benchmark.prototype.stats`](#benchmarkprototypestats)
* [`Benchmark.prototype.stats.deviation`](#benchmark-statsdeviation)
* [`Benchmark.prototype.stats.mean`](#benchmark-statsmean)
* [`Benchmark.prototype.stats.moe`](#benchmark-statsmoe)
* [`Benchmark.prototype.stats.rme`](#benchmark-statsrme)
* [`Benchmark.prototype.stats.sample`](#benchmark-statssample)
* [`Benchmark.prototype.stats.sem`](#benchmark-statssem)
* [`Benchmark.prototype.stats.variance`](#benchmark-statsvariance)
## `Benchmark.prototype.times`
* [`Benchmark.prototype.times`](#benchmarkprototypetimes)
* [`Benchmark.prototype.times.cycle`](#benchmark-timescycle)
* [`Benchmark.prototype.times.elapsed`](#benchmark-timeselapsed)
* [`Benchmark.prototype.times.period`](#benchmark-timesperiod)
* [`Benchmark.prototype.times.timeStamp`](#benchmark-timestimestamp)
## `Benchmark.Deferred`
* [`Benchmark.Deferred`](#benchmarkdeferredclone)
## `Benchmark.Deferred.prototype`
* [`Benchmark.Deferred.prototype.benchmark`](#benchmarkdeferredprototypebenchmark)
* [`Benchmark.Deferred.prototype.cycles`](#benchmarkdeferredprototypecycles)
* [`Benchmark.Deferred.prototype.elapsed`](#benchmarkdeferredprototypeelapsed)
* [`Benchmark.Deferred.prototype.resolve`](#benchmarkdeferredprototyperesolve)
* [`Benchmark.Deferred.prototype.timeStamp`](#benchmarkdeferredprototypetimestamp)
## `Benchmark.Event`
* [`Benchmark.Event`](#benchmarkeventtype)
## `Benchmark.Event.prototype`
* [`Benchmark.Event.prototype.aborted`](#benchmarkeventprototypeaborted)
* [`Benchmark.Event.prototype.cancelled`](#benchmarkeventprototypecancelled)
* [`Benchmark.Event.prototype.result`](#benchmarkeventprototyperesult)
* [`Benchmark.Event.prototype.timeStamp`](#benchmarkeventprototypetimestamp)
* [`Benchmark.Event.prototype.type`](#benchmarkeventprototypetype)
## `Benchmark.Event.prototype.currentTarget`
* [`Benchmark.Event.prototype.currentTarget`](#benchmarkeventprototypecurrenttarget)
## `Benchmark.Event.prototype.target`
* [`Benchmark.Event.prototype.target`](#benchmarkeventprototypetarget)
## `Benchmark.Suite`
* [`Benchmark.Suite`](#benchmarksuitename--options)
## `Benchmark.Suite.prototype`
* [`Benchmark.Suite.prototype.aborted`](#benchmarksuiteprototypeaborted)
* [`Benchmark.Suite.prototype.length`](#benchmarksuiteprototypelength)
* [`Benchmark.Suite.prototype.running`](#benchmarksuiteprototyperunning)
* [`Benchmark.Suite.prototype.abort`](#benchmarksuiteprototypeabort)
* [`Benchmark.Suite.prototype.add`](#benchmarksuiteprototypeaddname-fn--options)
* [`Benchmark.Suite.prototype.clone`](#benchmarksuiteprototypecloneoptions)
* [`Benchmark.Suite.prototype.emit`](#benchmarkprototypeemittype)
* [`Benchmark.Suite.prototype.filter`](#benchmarksuiteprototypefiltercallback)
* [`Benchmark.Suite.prototype.forEach`](#benchmarksuiteprototypeforeachcallback)
* [`Benchmark.Suite.prototype.indexOf`](#benchmarksuiteprototypeindexofvalue)
* [`Benchmark.Suite.prototype.invoke`](#benchmarksuiteprototypeinvokename--arg1-arg2-)
* [`Benchmark.Suite.prototype.join`](#benchmarksuiteprototypejoinseparator-)
* [`Benchmark.Suite.prototype.listeners`](#benchmarkprototypelistenerstype)
* [`Benchmark.Suite.prototype.map`](#benchmarksuiteprototypemapcallback)
* [`Benchmark.Suite.prototype.off`](#benchmarkprototypeofftype-listener)
* [`Benchmark.Suite.prototype.on`](#benchmarkprototypeontype-listener)
* [`Benchmark.Suite.prototype.pluck`](#benchmarksuiteprototypepluckproperty)
* [`Benchmark.Suite.prototype.pop`](#benchmarksuiteprototypepop)
* [`Benchmark.Suite.prototype.push`](#benchmarksuiteprototypepush)
* [`Benchmark.Suite.prototype.reduce`](#benchmarksuiteprototypereducecallback-accumulator)
* [`Benchmark.Suite.prototype.reset`](#benchmarksuiteprototypereset)
* [`Benchmark.Suite.prototype.reverse`](#benchmarksuiteprototypereverse)
* [`Benchmark.Suite.prototype.run`](#benchmarksuiteprototyperunoptions)
* [`Benchmark.Suite.prototype.shift`](#benchmarksuiteprototypeshift)
* [`Benchmark.Suite.prototype.slice`](#benchmarksuiteprototypeslicestart-end)
* [`Benchmark.Suite.prototype.sort`](#benchmarksuiteprototypesortcomparefnnull)
* [`Benchmark.Suite.prototype.splice`](#benchmarksuiteprototypesplicestart-deletecount--val1-val2-)
* [`Benchmark.Suite.prototype.unshift`](#benchmarksuiteprototypeunshift)
## `Benchmark.Suite.options`
* [`Benchmark.Suite.options`](#benchmarksuiteoptions)
* [`Benchmark.Suite.options.name`](#benchmarksuiteoptionsname)
## `Benchmark`
### `Benchmark(name, fn [, options={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L404 "View in source") [Ⓣ][1]
The Benchmark constructor.
#### Arguments
1. `name` *(String)*: A name to identify the benchmark.
2. `fn` *(Function|String)*: The test to benchmark.
3. `[options={}]` *(Object)*: Options object.
#### Example
~~~ js
// basic usage (the `new` operator is optional)
var bench = new Benchmark(fn);
// or using a name first
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',
// called when the benchmark starts running
'onStart': onStart,
// called after each run cycle
'onCycle': onCycle,
// called when aborted
'onAbort': onAbort,
// called when a test errors
'onError': onError,
// called when reset
'onReset': onReset,
// called when the benchmark completes running
'onComplete': onComplete,
// compiled/called before the test loop
'setup': setup,
// compiled/called after the test loop
'teardown': teardown
});
// or name and options
var bench = new Benchmark('foo', {
// a flag to indicate the benchmark is deferred
'defer': true,
// benchmark test function
'fn': function(deferred) {
// call resolve() when the deferred test is finished
deferred.resolve();
}
});
// or options only
var bench = new Benchmark({
// benchmark name
'name': 'foo',
// benchmark test as a string
'fn': '[1,2,3,4].sort()'
});
// 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
});
~~~
* * *
### `Benchmark.version`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3267 "View in source") [Ⓣ][1]
*(String)*: The semantic version number.
* * *
### `Benchmark.deepClone(value)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1225 "View in source") [Ⓣ][1]
A deep clone utility.
#### Arguments
1. `value` *(Mixed)*: The value to clone.
#### Returns
*(Mixed)*: The cloned value.
* * *
### `Benchmark.each(object, callback, thisArg)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1400 "View in source") [Ⓣ][1]
An iteration utility for arrays and objects. Callbacks may terminate the loop by explicitly returning `false`.
#### Arguments
1. `object` *(Array|Object)*: The object to iterate over.
2. `callback` *(Function)*: The function called per iteration.
3. `thisArg` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array, Object)*: Returns the object iterated over.
* * *
### `Benchmark.extend(destination [, source={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1446 "View in source") [Ⓣ][1]
Copies enumerable properties from the source(s) object to the destination object.
#### Arguments
1. `destination` *(Object)*: The destination object.
2. `[source={}]` *(Object)*: The source object.
#### Returns
*(Object)*: The destination object.
* * *
### `Benchmark.filter(array, callback, thisArg)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1485 "View in source") [Ⓣ][1]
A generic `Array#filter` like method.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `callback` *(Function|String)*: The function/alias called per iteration.
3. `thisArg` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: A new array of values that passed callback filter.
#### Example
~~~ 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 slowest benchmarks
Benchmark.filter(benches, 'slowest');
// get benchmarks that completed without erroring
Benchmark.filter(benches, 'successful');
~~~
* * *
### `Benchmark.forEach(array, callback, thisArg)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1518 "View in source") [Ⓣ][1]
A generic `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `callback` *(Function)*: The function called per iteration.
3. `thisArg` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: Returns the array iterated over.
* * *
### `Benchmark.formatNumber(number)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1557 "View in source") [Ⓣ][1]
Converts a number to a more readable comma-separated string representation.
#### Arguments
1. `number` *(Number)*: The number to convert.
#### Returns
*(String)*: The more readable string representation.
* * *
### `Benchmark.forOwn(object, callback, thisArg)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1545 "View in source") [Ⓣ][1]
Iterates over an object's own properties, executing the `callback` for each. Callbacks may terminate the loop by explicitly returning `false`.
#### Arguments
1. `object` *(Object)*: The object to iterate over.
2. `callback` *(Function)*: The function executed per own property.
3. `thisArg` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Object)*: Returns the object iterated over.
* * *
### `Benchmark.hasKey(object, key)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1572 "View in source") [Ⓣ][1]
Checks if an object has the specified key as a direct property.
#### 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`.
* * *
### `Benchmark.indexOf(array, value [, fromIndex=0])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1608 "View in source") [Ⓣ][1]
A generic `Array#indexOf` like method.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `value` *(Mixed)*: The value to search for.
3. `[fromIndex=0]` *(Number)*: The index to start searching from.
#### Returns
*(Number)*: The index of the matched value or `-1`.
* * *
### `Benchmark.interpolate(string, object)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1630 "View in source") [Ⓣ][1]
Modify a string by replacing named tokens with matching object property values.
#### Arguments
1. `string` *(String)*: The string to modify.
2. `object` *(Object)*: The template object.
#### Returns
*(String)*: The modified string.
* * *
### `Benchmark.invoke(benches, name [, arg1, arg2, ...])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1677 "View in source") [Ⓣ][1]
Invokes a method on all items in an array.
#### Arguments
1. `benches` *(Array)*: Array of benchmarks to iterate over.
2. `name` *(String|Object)*: The name of the method to invoke OR options object.
3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
#### Returns
*(Array)*: A new array of values returned from each method invoked.
#### Example
~~~ js
// invoke `reset` on all benchmarks
Benchmark.invoke(benches, 'reset');
// 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 the `run` method
'name': 'run',
// pass a single argument
'args': true,
// treat as queue, removing benchmarks from front of `benches` until empty
'queued': true,
// called before any benchmarks have been invoked.
'onStart': onStart,
// called between invoking benchmarks
'onCycle': onCycle,
// called after all benchmarks have been invoked.
'onComplete': onComplete
});
~~~
* * *
### `Benchmark.join(object [, separator1=',', separator2=': '])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1831 "View in source") [Ⓣ][1]
Creates a string of joined array values or object key-value pairs.
#### Arguments
1. `object` *(Array|Object)*: The object to operate on.
2. `[separator1=',']` *(String)*: The separator used between key-value pairs.
3. `[separator2=': ']` *(String)*: The separator used between keys and values.
#### Returns
*(String)*: The joined result.
* * *
### `Benchmark.map(array, callback, thisArg)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1853 "View in source") [Ⓣ][1]
A generic `Array#map` like method.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `callback` *(Function)*: The function called per iteration.
3. `thisArg` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: A new array of values returned by the callback.
* * *
### `Benchmark.pluck(array, property)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1869 "View in source") [Ⓣ][1]
Retrieves the value of a specified property from all items in an array.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `property` *(String)*: The property to pluck.
#### Returns
*(Array)*: A new array of property values.
* * *
### `Benchmark.reduce(array, callback, accumulator)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1885 "View in source") [Ⓣ][1]
A generic `Array#reduce` like method.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
2. `callback` *(Function)*: The function called per iteration.
3. `accumulator` *(Mixed)*: Initial value of the accumulator.
#### Returns
*(Mixed)*: The accumulator.
* * *
## `Benchmark.prototype`
### `Benchmark.prototype.aborted`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3377 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the benchmark is aborted.
* * *
### `Benchmark.prototype.compiled`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3353 "View in source") [Ⓣ][1]
*(Function, String)*: The compiled test function.
* * *
### `Benchmark.prototype.count`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3329 "View in source") [Ⓣ][1]
*(Number)*: The number of times a test was executed.
* * *
### `Benchmark.prototype.cycles`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3337 "View in source") [Ⓣ][1]
*(Number)*: The number of cycles performed while benchmarking.
* * *
### `Benchmark.prototype.fn`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3369 "View in source") [Ⓣ][1]
*(Function, String)*: The test to benchmark.
* * *
### `Benchmark.prototype.hz`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3345 "View in source") [Ⓣ][1]
*(Number)*: The number of executions per second.
* * *
### `Benchmark.prototype.running`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3385 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the benchmark is running.
* * *
### `Benchmark.prototype.setup`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3448 "View in source") [Ⓣ][1]
*(Function, String)*: Compiled into the test and executed immediately **before** the test loop.
#### Example
~~~ js
// basic usage
var bench = Benchmark({
'setup': function() {
var c = this.count,
element = document.getElementById('container');
while (c--) {
element.appendChild(document.createElement('div'));
}
},
'fn': function() {
element.removeChild(element.lastChild);
}
});
// compiles to something like:
var c = this.count,
element = document.getElementById('container');
while (c--) {
element.appendChild(document.createElement('div'));
}
var start = new Date;
while (count--) {
element.removeChild(element.lastChild);
}
var end = new Date - start;
// or using strings
var bench = Benchmark({
'setup': '\
var a = 0;\n\
(function() {\n\
(function() {\n\
(function() {',
'fn': 'a += 1;',
'teardown': '\
}())\n\
}())\n\
}())'
});
// compiles to something like:
var a = 0;
(function() {
(function() {
(function() {
var start = new Date;
while (count--) {
a += 1;
}
var end = new Date - start;
}())
}())
}())
~~~
* * *
### `Benchmark.prototype.teardown`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3456 "View in source") [Ⓣ][1]
*(Function, String)*: Compiled into the test and executed immediately **after** the test loop.
* * *
### `Benchmark.prototype.abort()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2218 "View in source") [Ⓣ][1]
Aborts the benchmark without recording times.
#### Returns
*(Object)*: The benchmark instance.
* * *
### `Benchmark.prototype.clone(options)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2257 "View in source") [Ⓣ][1]
Creates a new benchmark using the same test and options.
#### Arguments
1. `options` *(Object)*: Options object to overwrite cloned options.
#### Returns
*(Object)*: The new benchmark instance.
#### Example
~~~ js
var bizarro = bench.clone({
'name': 'doppelganger'
});
~~~
* * *
### `Benchmark.prototype.compare(other)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2280 "View in source") [Ⓣ][1]
Determines if a benchmark is faster than another.
#### Arguments
1. `other` *(Object)*: The benchmark to compare.
#### Returns
*(Number)*: Returns `-1` if slower, `1` if faster, and `0` if indeterminate.
* * *
### `Benchmark.Suite.prototype.emit(type)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1]
Executes all registered listeners of the specified event type.
#### Arguments
1. `type` *(String|Object)*: The event type or object.
#### Returns
*(Mixed)*: Returns the return value of the last listener executed.
* * *
### `Benchmark.Suite.prototype.listeners(type)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1]
Returns an array of event listeners for a given type that can be manipulated to add or remove listeners.
#### Arguments
1. `type` *(String)*: The event type.
#### Returns
*(Array)*: The listeners array.
* * *
### `Benchmark.Suite.prototype.off([type, listener])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1]
Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types.
#### Arguments
1. `[type]` *(String)*: The event type.
2. `[listener]` *(Function)*: The function to unregister.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// unregister a listener for an event type
bench.off('cycle', listener);
// unregister a listener for multiple event types
bench.off('start cycle', listener);
// unregister all listeners for an event type
bench.off('cycle');
// unregister all listeners for multiple event types
bench.off('start cycle complete');
// unregister all listeners for all event types
bench.off();
~~~
* * *
### `Benchmark.Suite.prototype.on(type, listener)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1]
Registers a listener for the specified event type(s).
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function to register.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// register a listener for an event type
bench.on('cycle', listener);
// register a listener for multiple event types
bench.on('start cycle', listener);
~~~
* * *
### `Benchmark.prototype.reset()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2334 "View in source") [Ⓣ][1]
Reset properties and abort if running.
#### Returns
*(Object)*: The benchmark instance.
* * *
### `Benchmark.prototype.run([options={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3000 "View in source") [Ⓣ][1]
Runs the benchmark.
#### Arguments
1. `[options={}]` *(Object)*: Options object.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// basic usage
bench.run();
// or with options
bench.run({ 'async': true });
~~~
* * *
### `Benchmark.prototype.toString()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2405 "View in source") [Ⓣ][1]
Displays relevant benchmark information when coerced to a string.
#### Returns
*(String)*: A string representation of the benchmark instance.
* * *
## `Benchmark.options`
### `Benchmark.options`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3049 "View in source") [Ⓣ][1]
*(Object)*: The default options copied by benchmark instances.
* * *
### `Benchmark.options.async`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3058 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate that benchmark cycles will execute asynchronously by default.
* * *
### `Benchmark.options.defer`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3066 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate that the benchmark clock is deferred.
* * *
### `Benchmark.options.delay`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3073 "View in source") [Ⓣ][1]
*(Number)*: The delay between test cycles *(secs)*.
* * *
### `Benchmark.options.id`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3082 "View in source") [Ⓣ][1]
*(String)*: Displayed by Benchmark#toString when a `name` is not available *(auto-generated if absent)*.
* * *
### `Benchmark.options.initCount`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3090 "View in source") [Ⓣ][1]
*(Number)*: The default number of times to execute a test on a benchmark's first cycle.
* * *
### `Benchmark.options.maxTime`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3099 "View in source") [Ⓣ][1]
*(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*. Note: Cycle delays aren't counted toward the maximum time.
* * *
### `Benchmark.options.minSamples`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3107 "View in source") [Ⓣ][1]
*(Number)*: The minimum sample size required to perform statistical analysis.
* * *
### `Benchmark.options.minTime`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3115 "View in source") [Ⓣ][1]
*(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*.
* * *
### `Benchmark.options.name`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3123 "View in source") [Ⓣ][1]
*(String)*: The name of the benchmark.
* * *
### `Benchmark.options.onAbort`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3131 "View in source") [Ⓣ][1]
An event listener called when the benchmark is aborted.
* * *
### `Benchmark.options.onComplete`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3139 "View in source") [Ⓣ][1]
An event listener called when the benchmark completes running.
* * *
### `Benchmark.options.onCycle`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3147 "View in source") [Ⓣ][1]
An event listener called after each run cycle.
* * *
### `Benchmark.options.onError`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3155 "View in source") [Ⓣ][1]
An event listener called when a test errors.
* * *
### `Benchmark.options.onReset`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3163 "View in source") [Ⓣ][1]
An event listener called when the benchmark is reset.
* * *
### `Benchmark.options.onStart`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3171 "View in source") [Ⓣ][1]
An event listener called when the benchmark starts running.
* * *
## `Benchmark.platform`
### `Benchmark.platform`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3182 "View in source") [Ⓣ][1]
*(Object)*: Platform object with properties describing things like browser name, version, and operating system.
* * *
### `Benchmark.platform.description`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3190 "View in source") [Ⓣ][1]
*(String)*: The platform description.
* * *
### `Benchmark.platform.layout`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3198 "View in source") [Ⓣ][1]
*(String, Null)*: The name of the browser layout engine.
* * *
### `Benchmark.platform.manufacturer`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3222 "View in source") [Ⓣ][1]
*(String, Null)*: The name of the product's manufacturer.
* * *
### `Benchmark.platform.name`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3214 "View in source") [Ⓣ][1]
*(String, Null)*: The name of the browser/environment.
* * *
### `Benchmark.platform.os`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3230 "View in source") [Ⓣ][1]
*(String, Null)*: The name of the operating system.
* * *
### `Benchmark.platform.prerelease`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3238 "View in source") [Ⓣ][1]
*(String, Null)*: The alpha/beta release indicator.
* * *
### `Benchmark.platform.product`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3206 "View in source") [Ⓣ][1]
*(String, Null)*: The name of the product hosting the browser.
* * *
### `Benchmark.platform.version`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3246 "View in source") [Ⓣ][1]
*(String, Null)*: The browser/environment version.
* * *
### `Benchmark.platform.toString()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3255 "View in source") [Ⓣ][1]
Return platform description when the platform object is coerced to a string.
#### Returns
*(String)*: The platform description.
* * *
## `Benchmark.support`
### `Benchmark.support`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L135 "View in source") [Ⓣ][1]
*(Object)*: An object used to flag environments/features.
* * *
### `Benchmark.support.air`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L145 "View in source") [Ⓣ][1]
*(Boolean)*: Detect Adobe AIR.
* * *
### `Benchmark.support.argumentsClass`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L153 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if `arguments` objects have the correct internal [[Class]] value.
* * *
### `Benchmark.support.browser`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L161 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if in a browser environment.
* * *
### `Benchmark.support.charByIndex`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L169 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if strings support accessing characters by index.
* * *
### `Benchmark.support.charByOwnIndex`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L179 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if strings have indexes as own properties.
* * *
### `Benchmark.support.decompilation`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L207 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if functions support decompilation.
* * *
### `Benchmark.support.descriptors`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L228 "View in source") [Ⓣ][1]
*(Boolean)*: Detect ES5+ property descriptor API.
* * *
### `Benchmark.support.getAllKeys`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L242 "View in source") [Ⓣ][1]
*(Boolean)*: Detect ES5+ Object.getOwnPropertyNames().
* * *
### `Benchmark.support.iteratesOwnFirst`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L255 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if own properties are iterated before inherited properties *(all but IE < `9`)*.
* * *
### `Benchmark.support.java`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L190 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if Java is enabled/exposed.
* * *
### `Benchmark.support.nodeClass`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L272 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if a node's [[Class]] is resolvable *(all but IE < `9`)* and that the JS engine errors when attempting to coerce an object to a string without a `toString` property value of `typeof` "function".
* * *
### `Benchmark.support.timeout`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L198 "View in source") [Ⓣ][1]
*(Boolean)*: Detect if the Timers API exists.
* * *
## `Benchmark.prototype.error`
### `Benchmark.prototype.error`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3361 "View in source") [Ⓣ][1]
*(Object)*: The error object if the test failed.
* * *
## `Benchmark.prototype.stats`
### `Benchmark.prototype.stats`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3464 "View in source") [Ⓣ][1]
*(Object)*: An object of stats including mean, margin or error, and standard deviation.
* * *
### `Benchmark.prototype.stats.deviation`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3496 "View in source") [Ⓣ][1]
*(Number)*: The sample standard deviation.
* * *
### `Benchmark.prototype.stats.mean`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3504 "View in source") [Ⓣ][1]
*(Number)*: The sample arithmetic mean.
* * *
### `Benchmark.prototype.stats.moe`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3472 "View in source") [Ⓣ][1]
*(Number)*: The margin of error.
* * *
### `Benchmark.prototype.stats.rme`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3480 "View in source") [Ⓣ][1]
*(Number)*: The relative margin of error *(expressed as a percentage of the mean)*.
* * *
### `Benchmark.prototype.stats.sample`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3512 "View in source") [Ⓣ][1]
*(Array)*: The array of sampled periods.
* * *
### `Benchmark.prototype.stats.sem`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3488 "View in source") [Ⓣ][1]
*(Number)*: The standard error of the mean.
* * *
### `Benchmark.prototype.stats.variance`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3520 "View in source") [Ⓣ][1]
*(Number)*: The sample variance.
* * *
## `Benchmark.prototype.times`
### `Benchmark.prototype.times`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3529 "View in source") [Ⓣ][1]
*(Object)*: An object of timing data including cycle, elapsed, period, start, and stop.
* * *
### `Benchmark.prototype.times.cycle`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3537 "View in source") [Ⓣ][1]
*(Number)*: The time taken to complete the last cycle *(secs)*.
* * *
### `Benchmark.prototype.times.elapsed`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3545 "View in source") [Ⓣ][1]
*(Number)*: The time taken to complete the benchmark *(secs)*.
* * *
### `Benchmark.prototype.times.period`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3553 "View in source") [Ⓣ][1]
*(Number)*: The time taken to execute the test once *(secs)*.
* * *
### `Benchmark.prototype.times.timeStamp`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3561 "View in source") [Ⓣ][1]
*(Number)*: A timestamp of when the benchmark started *(ms)*.
* * *
## `Benchmark.Deferred`
### `Benchmark.Deferred(clone)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L445 "View in source") [Ⓣ][1]
The Deferred constructor.
#### Arguments
1. `clone` *(Object)*: The cloned benchmark instance.
* * *
## `Benchmark.Deferred.prototype`
### `Benchmark.Deferred.prototype.benchmark`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3605 "View in source") [Ⓣ][1]
*(Object)*: The deferred benchmark instance.
* * *
### `Benchmark.Deferred.prototype.cycles`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3613 "View in source") [Ⓣ][1]
*(Number)*: The number of deferred cycles performed while benchmarking.
* * *
### `Benchmark.Deferred.prototype.elapsed`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3621 "View in source") [Ⓣ][1]
*(Number)*: The time taken to complete the deferred benchmark *(secs)*.
* * *
### `Benchmark.Deferred.prototype.resolve`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1188 "View in source") [Ⓣ][1]
*(Unknown)*: Handles cycling/completing the deferred benchmark.
* * *
### `Benchmark.Deferred.prototype.timeStamp`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3629 "View in source") [Ⓣ][1]
*(Number)*: A timestamp of when the deferred benchmark started *(ms)*.
* * *
## `Benchmark.Event`
### `Benchmark.Event(type)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L461 "View in source") [Ⓣ][1]
The Event constructor.
#### Arguments
1. `type` *(String|Object)*: The event type.
* * *
## `Benchmark.Event.prototype`
### `Benchmark.Event.prototype.aborted`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3645 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the emitters listener iteration is aborted.
* * *
### `Benchmark.Event.prototype.cancelled`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3653 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the default action is cancelled.
* * *
### `Benchmark.Event.prototype.result`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3669 "View in source") [Ⓣ][1]
*(Mixed)*: The return value of the last executed listener.
* * *
### `Benchmark.Event.prototype.timeStamp`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3685 "View in source") [Ⓣ][1]
*(Number)*: A timestamp of when the event was created *(ms)*.
* * *
### `Benchmark.Event.prototype.type`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3693 "View in source") [Ⓣ][1]
*(String)*: The event type.
* * *
## `Benchmark.Event.prototype.currentTarget`
### `Benchmark.Event.prototype.currentTarget`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3661 "View in source") [Ⓣ][1]
*(Object)*: The object whose listeners are currently being processed.
* * *
## `Benchmark.Event.prototype.target`
### `Benchmark.Event.prototype.target`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3677 "View in source") [Ⓣ][1]
*(Object)*: The object to which the event was originally emitted.
* * *
## `Benchmark.Suite`
### `Benchmark.Suite(name [, options={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L507 "View in source") [Ⓣ][1]
The Suite constructor.
#### Arguments
1. `name` *(String)*: A name to identify the suite.
2. `[options={}]` *(Object)*: Options object.
#### Example
~~~ js
// basic usage (the `new` operator is optional)
var suite = new Benchmark.Suite;
// or using a name first
var suite = new Benchmark.Suite('foo');
// or with options
var suite = new Benchmark.Suite('foo', {
// called when the suite starts running
'onStart': onStart,
// called between running benchmarks
'onCycle': onCycle,
// called when aborted
'onAbort': onAbort,
// called when a test errors
'onError': onError,
// called when reset
'onReset': onReset,
// called when the suite completes running
'onComplete': onComplete
});
~~~
* * *
## `Benchmark.Suite.prototype`
### `Benchmark.Suite.prototype.aborted`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3734 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the suite is aborted.
* * *
### `Benchmark.Suite.prototype.length`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3726 "View in source") [Ⓣ][1]
*(Number)*: The number of benchmarks in the suite.
* * *
### `Benchmark.Suite.prototype.running`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3742 "View in source") [Ⓣ][1]
*(Boolean)*: A flag to indicate if the suite is running.
* * *
### `Benchmark.Suite.prototype.abort()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1902 "View in source") [Ⓣ][1]
Aborts all benchmarks in the suite.
#### Returns
*(Object)*: The suite instance.
* * *
### `Benchmark.Suite.prototype.add(name, fn [, options={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1962 "View in source") [Ⓣ][1]
Adds a test to the benchmark suite.
#### Arguments
1. `name` *(String)*: A name to identify the benchmark.
2. `fn` *(Function|String)*: The test to benchmark.
3. `[options={}]` *(Object)*: Options object.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// basic usage
suite.add(fn);
// or using a name first
suite.add('foo', fn);
// or with options
suite.add('foo', fn, {
'onCycle': onCycle,
'onComplete': onComplete
});
// or name and options
suite.add('foo', {
'fn': fn,
'onCycle': onCycle,
'onComplete': onComplete
});
// or options only
suite.add({
'name': 'foo',
'fn': fn,
'onCycle': onCycle,
'onComplete': onComplete
});
~~~
* * *
### `Benchmark.Suite.prototype.clone(options)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1981 "View in source") [Ⓣ][1]
Creates a new suite with cloned benchmarks.
#### Arguments
1. `options` *(Object)*: Options object to overwrite cloned options.
#### Returns
*(Object)*: The new suite instance.
* * *
### `Benchmark.Suite.prototype.emit(type)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1]
Executes all registered listeners of the specified event type.
#### Arguments
1. `type` *(String|Object)*: The event type or object.
#### Returns
*(Mixed)*: Returns the return value of the last listener executed.
* * *
### `Benchmark.Suite.prototype.filter(callback)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2004 "View in source") [Ⓣ][1]
An `Array#filter` like method.
#### Arguments
1. `callback` *(Function|String)*: The function/alias called per iteration.
#### Returns
*(Object)*: A new suite of benchmarks that passed callback filter.
* * *
### `Benchmark.Suite.prototype.forEach(callback)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3752 "View in source") [Ⓣ][1]
An `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`.
#### Arguments
1. `callback` *(Function)*: The function called per iteration.
#### Returns
*(Object)*: The suite iterated over.
* * *
### `Benchmark.Suite.prototype.indexOf(value)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3761 "View in source") [Ⓣ][1]
An `Array#indexOf` like method.
#### Arguments
1. `value` *(Mixed)*: The value to search for.
#### Returns
*(Number)*: The index of the matched value or `-1`.
* * *
### `Benchmark.Suite.prototype.invoke(name [, arg1, arg2, ...])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3771 "View in source") [Ⓣ][1]
Invokes a method on all benchmarks in the suite.
#### Arguments
1. `name` *(String|Object)*: The name of the method to invoke OR options object.
2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
#### Returns
*(Array)*: A new array of values returned from each method invoked.
* * *
### `Benchmark.Suite.prototype.join([separator=','])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3780 "View in source") [Ⓣ][1]
Converts the suite of benchmarks to a string.
#### Arguments
1. `[separator=',']` *(String)*: A string to separate each element of the array.
#### Returns
*(String)*: The string.
* * *
### `Benchmark.Suite.prototype.listeners(type)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1]
Returns an array of event listeners for a given type that can be manipulated to add or remove listeners.
#### Arguments
1. `type` *(String)*: The event type.
#### Returns
*(Array)*: The listeners array.
* * *
### `Benchmark.Suite.prototype.map(callback)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3789 "View in source") [Ⓣ][1]
An `Array#map` like method.
#### Arguments
1. `callback` *(Function)*: The function called per iteration.
#### Returns
*(Array)*: A new array of values returned by the callback.
* * *
### `Benchmark.Suite.prototype.off([type, listener])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1]
Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types.
#### Arguments
1. `[type]` *(String)*: The event type.
2. `[listener]` *(Function)*: The function to unregister.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// unregister a listener for an event type
bench.off('cycle', listener);
// unregister a listener for multiple event types
bench.off('start cycle', listener);
// unregister all listeners for an event type
bench.off('cycle');
// unregister all listeners for multiple event types
bench.off('start cycle complete');
// unregister all listeners for all event types
bench.off();
~~~
* * *
### `Benchmark.Suite.prototype.on(type, listener)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1]
Registers a listener for the specified event type(s).
#### Arguments
1. `type` *(String)*: The event type.
2. `listener` *(Function)*: The function to register.
#### Returns
*(Object)*: The benchmark instance.
#### Example
~~~ js
// register a listener for an event type
bench.on('cycle', listener);
// register a listener for multiple event types
bench.on('start cycle', listener);
~~~
* * *
### `Benchmark.Suite.prototype.pluck(property)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3798 "View in source") [Ⓣ][1]
Retrieves the value of a specified property from all benchmarks in the suite.
#### Arguments
1. `property` *(String)*: The property to pluck.
#### Returns
*(Array)*: A new array of property values.
* * *
### `Benchmark.Suite.prototype.pop()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3806 "View in source") [Ⓣ][1]
Removes the last benchmark from the suite and returns it.
#### Returns
*(Mixed)*: The removed benchmark.
* * *
### `Benchmark.Suite.prototype.push()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3814 "View in source") [Ⓣ][1]
Appends benchmarks to the suite.
#### Returns
*(Number)*: The suite's new length.
* * *
### `Benchmark.Suite.prototype.reduce(callback, accumulator)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3833 "View in source") [Ⓣ][1]
An `Array#reduce` like method.
#### Arguments
1. `callback` *(Function)*: The function called per iteration.
2. `accumulator` *(Mixed)*: Initial value of the accumulator.
#### Returns
*(Mixed)*: The accumulator.
* * *
### `Benchmark.Suite.prototype.reset()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2019 "View in source") [Ⓣ][1]
Resets all benchmarks in the suite.
#### Returns
*(Object)*: The suite instance.
* * *
### `Benchmark.Suite.prototype.reverse()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L638 "View in source") [Ⓣ][1]
Rearrange the host array's elements in reverse order.
#### Returns
*(Array)*: The reversed array.
* * *
### `Benchmark.Suite.prototype.run([options={}])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2056 "View in source") [Ⓣ][1]
Runs the suite.
#### Arguments
1. `[options={}]` *(Object)*: Options object.
#### Returns
*(Object)*: The suite instance.
#### Example
~~~ js
// basic usage
suite.run();
// or with options
suite.run({ 'async': true, 'queued': true });
~~~
* * *
### `Benchmark.Suite.prototype.shift()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L671 "View in source") [Ⓣ][1]
Removes the first element of the host array and returns it.
#### Returns
*(Mixed)*: The first element of the array.
* * *
### `Benchmark.Suite.prototype.slice(start, end)`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L684 "View in source") [Ⓣ][1]
Creates an array of the host array's elements from the start index up to, but not including, the end index.
#### Arguments
1. `start` *(Number)*: The starting index.
2. `end` *(Number)*: The end index.
#### Returns
*(Array)*: The new array.
* * *
### `Benchmark.Suite.prototype.sort([compareFn=null])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3823 "View in source") [Ⓣ][1]
Sorts the benchmarks of the suite.
#### Arguments
1. `[compareFn=null]` *(Function)*: A function that defines the sort order.
#### Returns
*(Object)*: The sorted suite.
* * *
### `Benchmark.Suite.prototype.splice(start, deleteCount [, val1, val2, ...])`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L714 "View in source") [Ⓣ][1]
Allows removing a range of elements and/or inserting elements into the host array.
#### Arguments
1. `start` *(Number)*: The start index.
2. `deleteCount` *(Number)*: The number of elements to delete.
3. `[val1, val2, ...]` *(Mixed)*: values to insert at the `start` index.
#### Returns
*(Array)*: An array of removed elements.
* * *
### `Benchmark.Suite.prototype.unshift()`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L749 "View in source") [Ⓣ][1]
Appends arguments to the host array.
#### Returns
*(Number)*: The new length.
* * *
## `Benchmark.Suite.options`
### `Benchmark.Suite.options`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3705 "View in source") [Ⓣ][1]
*(Object)*: The default options copied by suite instances.
* * *
### `Benchmark.Suite.options.name`
# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3713 "View in source") [Ⓣ][1]
*(String)*: The name of the suite.
* * *
[1]: #Benchmark "Jump back to the TOC."