You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2628 lines
69 KiB

  1. # Benchmark.js <sup>v1.0.0</sup>
  2. <!-- div -->
  3. <!-- div -->
  4. ## <a id="Benchmark"></a>`Benchmark`
  5. * [`Benchmark`](#benchmarkname-fn--options)
  6. * [`Benchmark.version`](#benchmarkversion)
  7. * [`Benchmark.deepClone`](#benchmarkdeepclonevalue)
  8. * [`Benchmark.each`](#benchmarkeachobject-callback-thisarg)
  9. * [`Benchmark.extend`](#benchmarkextenddestination--source)
  10. * [`Benchmark.filter`](#benchmarkfilterarray-callback-thisarg)
  11. * [`Benchmark.forEach`](#benchmarkforeacharray-callback-thisarg)
  12. * [`Benchmark.formatNumber`](#benchmarkformatnumbernumber)
  13. * [`Benchmark.forOwn`](#benchmarkforownobject-callback-thisarg)
  14. * [`Benchmark.hasKey`](#benchmarkhaskeyobject-key)
  15. * [`Benchmark.indexOf`](#benchmarkindexofarray-value--fromindex0)
  16. * [`Benchmark.interpolate`](#benchmarkinterpolatestring-object)
  17. * [`Benchmark.invoke`](#benchmarkinvokebenches-name--arg1-arg2-)
  18. * [`Benchmark.join`](#benchmarkjoinobject--separator1--separator2:)
  19. * [`Benchmark.map`](#benchmarkmaparray-callback-thisarg)
  20. * [`Benchmark.pluck`](#benchmarkpluckarray-property)
  21. * [`Benchmark.reduce`](#benchmarkreducearray-callback-accumulator)
  22. <!-- /div -->
  23. <!-- div -->
  24. ## `Benchmark.prototype`
  25. * [`Benchmark.prototype.aborted`](#benchmarkprototypeaborted)
  26. * [`Benchmark.prototype.compiled`](#benchmarkprototypecompiled)
  27. * [`Benchmark.prototype.count`](#benchmarkprototypecount)
  28. * [`Benchmark.prototype.cycles`](#benchmarkprototypecycles)
  29. * [`Benchmark.prototype.fn`](#benchmarkprototypefn)
  30. * [`Benchmark.prototype.hz`](#benchmarkprototypehz)
  31. * [`Benchmark.prototype.running`](#benchmarkprototyperunning)
  32. * [`Benchmark.prototype.setup`](#benchmarkprototypesetup)
  33. * [`Benchmark.prototype.teardown`](#benchmarkprototypeteardown)
  34. * [`Benchmark.prototype.abort`](#benchmarkprototypeabort)
  35. * [`Benchmark.prototype.clone`](#benchmarkprototypecloneoptions)
  36. * [`Benchmark.prototype.compare`](#benchmarkprototypecompareother)
  37. * [`Benchmark.prototype.emit`](#benchmarkprototypeemittype)
  38. * [`Benchmark.prototype.listeners`](#benchmarkprototypelistenerstype)
  39. * [`Benchmark.prototype.off`](#benchmarkprototypeofftype-listener)
  40. * [`Benchmark.prototype.on`](#benchmarkprototypeontype-listener)
  41. * [`Benchmark.prototype.reset`](#benchmarkprototypereset)
  42. * [`Benchmark.prototype.run`](#benchmarkprototyperunoptions)
  43. * [`Benchmark.prototype.toString`](#benchmarkprototypetostring)
  44. <!-- /div -->
  45. <!-- div -->
  46. ## `Benchmark.options`
  47. * [`Benchmark.options`](#benchmarkoptions)
  48. * [`Benchmark.options.async`](#benchmarkoptionsasync)
  49. * [`Benchmark.options.defer`](#benchmarkoptionsdefer)
  50. * [`Benchmark.options.delay`](#benchmarkoptionsdelay)
  51. * [`Benchmark.options.id`](#benchmarkoptionsid)
  52. * [`Benchmark.options.initCount`](#benchmarkoptionsinitcount)
  53. * [`Benchmark.options.maxTime`](#benchmarkoptionsmaxtime)
  54. * [`Benchmark.options.minSamples`](#benchmarkoptionsminsamples)
  55. * [`Benchmark.options.minTime`](#benchmarkoptionsmintime)
  56. * [`Benchmark.options.name`](#benchmarkoptionsname)
  57. * [`Benchmark.options.onAbort`](#benchmarkoptionsonabort)
  58. * [`Benchmark.options.onComplete`](#benchmarkoptionsoncomplete)
  59. * [`Benchmark.options.onCycle`](#benchmarkoptionsoncycle)
  60. * [`Benchmark.options.onError`](#benchmarkoptionsonerror)
  61. * [`Benchmark.options.onReset`](#benchmarkoptionsonreset)
  62. * [`Benchmark.options.onStart`](#benchmarkoptionsonstart)
  63. <!-- /div -->
  64. <!-- div -->
  65. ## `Benchmark.platform`
  66. * [`Benchmark.platform`](#benchmarkplatform)
  67. * [`Benchmark.platform.description`](#benchmarkplatformdescription)
  68. * [`Benchmark.platform.layout`](#benchmarkplatformlayout)
  69. * [`Benchmark.platform.manufacturer`](#benchmarkplatformmanufacturer)
  70. * [`Benchmark.platform.name`](#benchmarkplatformname)
  71. * [`Benchmark.platform.os`](#benchmarkplatformos)
  72. * [`Benchmark.platform.prerelease`](#benchmarkplatformprerelease)
  73. * [`Benchmark.platform.product`](#benchmarkplatformproduct)
  74. * [`Benchmark.platform.version`](#benchmarkplatformversion)
  75. * [`Benchmark.platform.toString`](#benchmarkplatformtostring)
  76. <!-- /div -->
  77. <!-- div -->
  78. ## `Benchmark.support`
  79. * [`Benchmark.support`](#benchmarksupport)
  80. * [`Benchmark.support.air`](#benchmarksupportair)
  81. * [`Benchmark.support.argumentsClass`](#benchmarksupportargumentsclass)
  82. * [`Benchmark.support.browser`](#benchmarksupportbrowser)
  83. * [`Benchmark.support.charByIndex`](#benchmarksupportcharbyindex)
  84. * [`Benchmark.support.charByOwnIndex`](#benchmarksupportcharbyownindex)
  85. * [`Benchmark.support.decompilation`](#benchmarksupportdecompilation)
  86. * [`Benchmark.support.descriptors`](#benchmarksupportdescriptors)
  87. * [`Benchmark.support.getAllKeys`](#benchmarksupportgetallkeys)
  88. * [`Benchmark.support.iteratesOwnLast`](#benchmarksupportiteratesownfirst)
  89. * [`Benchmark.support.java`](#benchmarksupportjava)
  90. * [`Benchmark.support.nodeClass`](#benchmarksupportnodeclass)
  91. * [`Benchmark.support.timeout`](#benchmarksupporttimeout)
  92. <!-- /div -->
  93. <!-- div -->
  94. ## `Benchmark.prototype.error`
  95. * [`Benchmark.prototype.error`](#benchmarkprototypeerror)
  96. <!-- /div -->
  97. <!-- div -->
  98. ## `Benchmark.prototype.stats`
  99. * [`Benchmark.prototype.stats`](#benchmarkprototypestats)
  100. * [`Benchmark.prototype.stats.deviation`](#benchmark-statsdeviation)
  101. * [`Benchmark.prototype.stats.mean`](#benchmark-statsmean)
  102. * [`Benchmark.prototype.stats.moe`](#benchmark-statsmoe)
  103. * [`Benchmark.prototype.stats.rme`](#benchmark-statsrme)
  104. * [`Benchmark.prototype.stats.sample`](#benchmark-statssample)
  105. * [`Benchmark.prototype.stats.sem`](#benchmark-statssem)
  106. * [`Benchmark.prototype.stats.variance`](#benchmark-statsvariance)
  107. <!-- /div -->
  108. <!-- div -->
  109. ## `Benchmark.prototype.times`
  110. * [`Benchmark.prototype.times`](#benchmarkprototypetimes)
  111. * [`Benchmark.prototype.times.cycle`](#benchmark-timescycle)
  112. * [`Benchmark.prototype.times.elapsed`](#benchmark-timeselapsed)
  113. * [`Benchmark.prototype.times.period`](#benchmark-timesperiod)
  114. * [`Benchmark.prototype.times.timeStamp`](#benchmark-timestimestamp)
  115. <!-- /div -->
  116. <!-- div -->
  117. ## `Benchmark.Deferred`
  118. * [`Benchmark.Deferred`](#benchmarkdeferredclone)
  119. <!-- /div -->
  120. <!-- div -->
  121. ## `Benchmark.Deferred.prototype`
  122. * [`Benchmark.Deferred.prototype.benchmark`](#benchmarkdeferredprototypebenchmark)
  123. * [`Benchmark.Deferred.prototype.cycles`](#benchmarkdeferredprototypecycles)
  124. * [`Benchmark.Deferred.prototype.elapsed`](#benchmarkdeferredprototypeelapsed)
  125. * [`Benchmark.Deferred.prototype.resolve`](#benchmarkdeferredprototyperesolve)
  126. * [`Benchmark.Deferred.prototype.timeStamp`](#benchmarkdeferredprototypetimestamp)
  127. <!-- /div -->
  128. <!-- div -->
  129. ## `Benchmark.Event`
  130. * [`Benchmark.Event`](#benchmarkeventtype)
  131. <!-- /div -->
  132. <!-- div -->
  133. ## `Benchmark.Event.prototype`
  134. * [`Benchmark.Event.prototype.aborted`](#benchmarkeventprototypeaborted)
  135. * [`Benchmark.Event.prototype.cancelled`](#benchmarkeventprototypecancelled)
  136. * [`Benchmark.Event.prototype.result`](#benchmarkeventprototyperesult)
  137. * [`Benchmark.Event.prototype.timeStamp`](#benchmarkeventprototypetimestamp)
  138. * [`Benchmark.Event.prototype.type`](#benchmarkeventprototypetype)
  139. <!-- /div -->
  140. <!-- div -->
  141. ## `Benchmark.Event.prototype.currentTarget`
  142. * [`Benchmark.Event.prototype.currentTarget`](#benchmarkeventprototypecurrenttarget)
  143. <!-- /div -->
  144. <!-- div -->
  145. ## `Benchmark.Event.prototype.target`
  146. * [`Benchmark.Event.prototype.target`](#benchmarkeventprototypetarget)
  147. <!-- /div -->
  148. <!-- div -->
  149. ## `Benchmark.Suite`
  150. * [`Benchmark.Suite`](#benchmarksuitename--options)
  151. <!-- /div -->
  152. <!-- div -->
  153. ## `Benchmark.Suite.prototype`
  154. * [`Benchmark.Suite.prototype.aborted`](#benchmarksuiteprototypeaborted)
  155. * [`Benchmark.Suite.prototype.length`](#benchmarksuiteprototypelength)
  156. * [`Benchmark.Suite.prototype.running`](#benchmarksuiteprototyperunning)
  157. * [`Benchmark.Suite.prototype.abort`](#benchmarksuiteprototypeabort)
  158. * [`Benchmark.Suite.prototype.add`](#benchmarksuiteprototypeaddname-fn--options)
  159. * [`Benchmark.Suite.prototype.clone`](#benchmarksuiteprototypecloneoptions)
  160. * [`Benchmark.Suite.prototype.emit`](#benchmarkprototypeemittype)
  161. * [`Benchmark.Suite.prototype.filter`](#benchmarksuiteprototypefiltercallback)
  162. * [`Benchmark.Suite.prototype.forEach`](#benchmarksuiteprototypeforeachcallback)
  163. * [`Benchmark.Suite.prototype.indexOf`](#benchmarksuiteprototypeindexofvalue)
  164. * [`Benchmark.Suite.prototype.invoke`](#benchmarksuiteprototypeinvokename--arg1-arg2-)
  165. * [`Benchmark.Suite.prototype.join`](#benchmarksuiteprototypejoinseparator-)
  166. * [`Benchmark.Suite.prototype.listeners`](#benchmarkprototypelistenerstype)
  167. * [`Benchmark.Suite.prototype.map`](#benchmarksuiteprototypemapcallback)
  168. * [`Benchmark.Suite.prototype.off`](#benchmarkprototypeofftype-listener)
  169. * [`Benchmark.Suite.prototype.on`](#benchmarkprototypeontype-listener)
  170. * [`Benchmark.Suite.prototype.pluck`](#benchmarksuiteprototypepluckproperty)
  171. * [`Benchmark.Suite.prototype.pop`](#benchmarksuiteprototypepop)
  172. * [`Benchmark.Suite.prototype.push`](#benchmarksuiteprototypepush)
  173. * [`Benchmark.Suite.prototype.reduce`](#benchmarksuiteprototypereducecallback-accumulator)
  174. * [`Benchmark.Suite.prototype.reset`](#benchmarksuiteprototypereset)
  175. * [`Benchmark.Suite.prototype.reverse`](#benchmarksuiteprototypereverse)
  176. * [`Benchmark.Suite.prototype.run`](#benchmarksuiteprototyperunoptions)
  177. * [`Benchmark.Suite.prototype.shift`](#benchmarksuiteprototypeshift)
  178. * [`Benchmark.Suite.prototype.slice`](#benchmarksuiteprototypeslicestart-end)
  179. * [`Benchmark.Suite.prototype.sort`](#benchmarksuiteprototypesortcomparefnnull)
  180. * [`Benchmark.Suite.prototype.splice`](#benchmarksuiteprototypesplicestart-deletecount--val1-val2-)
  181. * [`Benchmark.Suite.prototype.unshift`](#benchmarksuiteprototypeunshift)
  182. <!-- /div -->
  183. <!-- div -->
  184. ## `Benchmark.Suite.options`
  185. * [`Benchmark.Suite.options`](#benchmarksuiteoptions)
  186. * [`Benchmark.Suite.options.name`](#benchmarksuiteoptionsname)
  187. <!-- /div -->
  188. <!-- /div -->
  189. <!-- div -->
  190. <!-- div -->
  191. ## `Benchmark`
  192. <!-- div -->
  193. ### <a id="benchmarkname-fn--options"></a>`Benchmark(name, fn [, options={}])`
  194. <a href="#benchmarkname-fn--options">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L404 "View in source") [&#x24C9;][1]
  195. The Benchmark constructor.
  196. #### Arguments
  197. 1. `name` *(String)*: A name to identify the benchmark.
  198. 2. `fn` *(Function|String)*: The test to benchmark.
  199. 3. `[options={}]` *(Object)*: Options object.
  200. #### Example
  201. ~~~ js
  202. // basic usage (the `new` operator is optional)
  203. var bench = new Benchmark(fn);
  204. // or using a name first
  205. var bench = new Benchmark('foo', fn);
  206. // or with options
  207. var bench = new Benchmark('foo', fn, {
  208. // displayed by Benchmark#toString if `name` is not available
  209. 'id': 'xyz',
  210. // called when the benchmark starts running
  211. 'onStart': onStart,
  212. // called after each run cycle
  213. 'onCycle': onCycle,
  214. // called when aborted
  215. 'onAbort': onAbort,
  216. // called when a test errors
  217. 'onError': onError,
  218. // called when reset
  219. 'onReset': onReset,
  220. // called when the benchmark completes running
  221. 'onComplete': onComplete,
  222. // compiled/called before the test loop
  223. 'setup': setup,
  224. // compiled/called after the test loop
  225. 'teardown': teardown
  226. });
  227. // or name and options
  228. var bench = new Benchmark('foo', {
  229. // a flag to indicate the benchmark is deferred
  230. 'defer': true,
  231. // benchmark test function
  232. 'fn': function(deferred) {
  233. // call resolve() when the deferred test is finished
  234. deferred.resolve();
  235. }
  236. });
  237. // or options only
  238. var bench = new Benchmark({
  239. // benchmark name
  240. 'name': 'foo',
  241. // benchmark test as a string
  242. 'fn': '[1,2,3,4].sort()'
  243. });
  244. // a test's `this` binding is set to the benchmark instance
  245. var bench = new Benchmark('foo', function() {
  246. 'My name is '.concat(this.name); // My name is foo
  247. });
  248. ~~~
  249. * * *
  250. <!-- /div -->
  251. <!-- div -->
  252. ### <a id="benchmarkversion"></a>`Benchmark.version`
  253. <a href="#benchmarkversion">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3267 "View in source") [&#x24C9;][1]
  254. *(String)*: The semantic version number.
  255. * * *
  256. <!-- /div -->
  257. <!-- div -->
  258. ### <a id="benchmarkdeepclonevalue"></a>`Benchmark.deepClone(value)`
  259. <a href="#benchmarkdeepclonevalue">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1225 "View in source") [&#x24C9;][1]
  260. A deep clone utility.
  261. #### Arguments
  262. 1. `value` *(Mixed)*: The value to clone.
  263. #### Returns
  264. *(Mixed)*: The cloned value.
  265. * * *
  266. <!-- /div -->
  267. <!-- div -->
  268. ### <a id="benchmarkeachobject-callback-thisarg"></a>`Benchmark.each(object, callback, thisArg)`
  269. <a href="#benchmarkeachobject-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1400 "View in source") [&#x24C9;][1]
  270. An iteration utility for arrays and objects. Callbacks may terminate the loop by explicitly returning `false`.
  271. #### Arguments
  272. 1. `object` *(Array|Object)*: The object to iterate over.
  273. 2. `callback` *(Function)*: The function called per iteration.
  274. 3. `thisArg` *(Mixed)*: The `this` binding for the callback.
  275. #### Returns
  276. *(Array, Object)*: Returns the object iterated over.
  277. * * *
  278. <!-- /div -->
  279. <!-- div -->
  280. ### <a id="benchmarkextenddestination--source"></a>`Benchmark.extend(destination [, source={}])`
  281. <a href="#benchmarkextenddestination--source">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1446 "View in source") [&#x24C9;][1]
  282. Copies enumerable properties from the source(s) object to the destination object.
  283. #### Arguments
  284. 1. `destination` *(Object)*: The destination object.
  285. 2. `[source={}]` *(Object)*: The source object.
  286. #### Returns
  287. *(Object)*: The destination object.
  288. * * *
  289. <!-- /div -->
  290. <!-- div -->
  291. ### <a id="benchmarkfilterarray-callback-thisarg"></a>`Benchmark.filter(array, callback, thisArg)`
  292. <a href="#benchmarkfilterarray-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1485 "View in source") [&#x24C9;][1]
  293. A generic `Array#filter` like method.
  294. #### Arguments
  295. 1. `array` *(Array)*: The array to iterate over.
  296. 2. `callback` *(Function|String)*: The function/alias called per iteration.
  297. 3. `thisArg` *(Mixed)*: The `this` binding for the callback.
  298. #### Returns
  299. *(Array)*: A new array of values that passed callback filter.
  300. #### Example
  301. ~~~ js
  302. // get odd numbers
  303. Benchmark.filter([1, 2, 3, 4, 5], function(n) {
  304. return n % 2;
  305. }); // -> [1, 3, 5];
  306. // get fastest benchmarks
  307. Benchmark.filter(benches, 'fastest');
  308. // get slowest benchmarks
  309. Benchmark.filter(benches, 'slowest');
  310. // get benchmarks that completed without erroring
  311. Benchmark.filter(benches, 'successful');
  312. ~~~
  313. * * *
  314. <!-- /div -->
  315. <!-- div -->
  316. ### <a id="benchmarkforeacharray-callback-thisarg"></a>`Benchmark.forEach(array, callback, thisArg)`
  317. <a href="#benchmarkforeacharray-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1518 "View in source") [&#x24C9;][1]
  318. A generic `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`.
  319. #### Arguments
  320. 1. `array` *(Array)*: The array to iterate over.
  321. 2. `callback` *(Function)*: The function called per iteration.
  322. 3. `thisArg` *(Mixed)*: The `this` binding for the callback.
  323. #### Returns
  324. *(Array)*: Returns the array iterated over.
  325. * * *
  326. <!-- /div -->
  327. <!-- div -->
  328. ### <a id="benchmarkformatnumbernumber"></a>`Benchmark.formatNumber(number)`
  329. <a href="#benchmarkformatnumbernumber">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1557 "View in source") [&#x24C9;][1]
  330. Converts a number to a more readable comma-separated string representation.
  331. #### Arguments
  332. 1. `number` *(Number)*: The number to convert.
  333. #### Returns
  334. *(String)*: The more readable string representation.
  335. * * *
  336. <!-- /div -->
  337. <!-- div -->
  338. ### <a id="benchmarkforownobject-callback-thisarg"></a>`Benchmark.forOwn(object, callback, thisArg)`
  339. <a href="#benchmarkforownobject-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1545 "View in source") [&#x24C9;][1]
  340. Iterates over an object's own properties, executing the `callback` for each. Callbacks may terminate the loop by explicitly returning `false`.
  341. #### Arguments
  342. 1. `object` *(Object)*: The object to iterate over.
  343. 2. `callback` *(Function)*: The function executed per own property.
  344. 3. `thisArg` *(Mixed)*: The `this` binding for the callback.
  345. #### Returns
  346. *(Object)*: Returns the object iterated over.
  347. * * *
  348. <!-- /div -->
  349. <!-- div -->
  350. ### <a id="benchmarkhaskeyobject-key"></a>`Benchmark.hasKey(object, key)`
  351. <a href="#benchmarkhaskeyobject-key">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1572 "View in source") [&#x24C9;][1]
  352. Checks if an object has the specified key as a direct property.
  353. #### Arguments
  354. 1. `object` *(Object)*: The object to check.
  355. 2. `key` *(String)*: The key to check for.
  356. #### Returns
  357. *(Boolean)*: Returns `true` if key is a direct property, else `false`.
  358. * * *
  359. <!-- /div -->
  360. <!-- div -->
  361. ### <a id="benchmarkindexofarray-value--fromindex0"></a>`Benchmark.indexOf(array, value [, fromIndex=0])`
  362. <a href="#benchmarkindexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1608 "View in source") [&#x24C9;][1]
  363. A generic `Array#indexOf` like method.
  364. #### Arguments
  365. 1. `array` *(Array)*: The array to iterate over.
  366. 2. `value` *(Mixed)*: The value to search for.
  367. 3. `[fromIndex=0]` *(Number)*: The index to start searching from.
  368. #### Returns
  369. *(Number)*: The index of the matched value or `-1`.
  370. * * *
  371. <!-- /div -->
  372. <!-- div -->
  373. ### <a id="benchmarkinterpolatestring-object"></a>`Benchmark.interpolate(string, object)`
  374. <a href="#benchmarkinterpolatestring-object">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1630 "View in source") [&#x24C9;][1]
  375. Modify a string by replacing named tokens with matching object property values.
  376. #### Arguments
  377. 1. `string` *(String)*: The string to modify.
  378. 2. `object` *(Object)*: The template object.
  379. #### Returns
  380. *(String)*: The modified string.
  381. * * *
  382. <!-- /div -->
  383. <!-- div -->
  384. ### <a id="benchmarkinvokebenches-name--arg1-arg2-"></a>`Benchmark.invoke(benches, name [, arg1, arg2, ...])`
  385. <a href="#benchmarkinvokebenches-name--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1677 "View in source") [&#x24C9;][1]
  386. Invokes a method on all items in an array.
  387. #### Arguments
  388. 1. `benches` *(Array)*: Array of benchmarks to iterate over.
  389. 2. `name` *(String|Object)*: The name of the method to invoke OR options object.
  390. 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
  391. #### Returns
  392. *(Array)*: A new array of values returned from each method invoked.
  393. #### Example
  394. ~~~ js
  395. // invoke `reset` on all benchmarks
  396. Benchmark.invoke(benches, 'reset');
  397. // invoke `emit` with arguments
  398. Benchmark.invoke(benches, 'emit', 'complete', listener);
  399. // invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks
  400. Benchmark.invoke(benches, {
  401. // invoke the `run` method
  402. 'name': 'run',
  403. // pass a single argument
  404. 'args': true,
  405. // treat as queue, removing benchmarks from front of `benches` until empty
  406. 'queued': true,
  407. // called before any benchmarks have been invoked.
  408. 'onStart': onStart,
  409. // called between invoking benchmarks
  410. 'onCycle': onCycle,
  411. // called after all benchmarks have been invoked.
  412. 'onComplete': onComplete
  413. });
  414. ~~~
  415. * * *
  416. <!-- /div -->
  417. <!-- div -->
  418. ### <a id="benchmarkjoinobject--separator1--separator2:"></a>`Benchmark.join(object [, separator1=',', separator2=': '])`
  419. <a href="#benchmarkjoinobject--separator1--separator2:">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1831 "View in source") [&#x24C9;][1]
  420. Creates a string of joined array values or object key-value pairs.
  421. #### Arguments
  422. 1. `object` *(Array|Object)*: The object to operate on.
  423. 2. `[separator1=',']` *(String)*: The separator used between key-value pairs.
  424. 3. `[separator2=': ']` *(String)*: The separator used between keys and values.
  425. #### Returns
  426. *(String)*: The joined result.
  427. * * *
  428. <!-- /div -->
  429. <!-- div -->
  430. ### <a id="benchmarkmaparray-callback-thisarg"></a>`Benchmark.map(array, callback, thisArg)`
  431. <a href="#benchmarkmaparray-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1853 "View in source") [&#x24C9;][1]
  432. A generic `Array#map` like method.
  433. #### Arguments
  434. 1. `array` *(Array)*: The array to iterate over.
  435. 2. `callback` *(Function)*: The function called per iteration.
  436. 3. `thisArg` *(Mixed)*: The `this` binding for the callback.
  437. #### Returns
  438. *(Array)*: A new array of values returned by the callback.
  439. * * *
  440. <!-- /div -->
  441. <!-- div -->
  442. ### <a id="benchmarkpluckarray-property"></a>`Benchmark.pluck(array, property)`
  443. <a href="#benchmarkpluckarray-property">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1869 "View in source") [&#x24C9;][1]
  444. Retrieves the value of a specified property from all items in an array.
  445. #### Arguments
  446. 1. `array` *(Array)*: The array to iterate over.
  447. 2. `property` *(String)*: The property to pluck.
  448. #### Returns
  449. *(Array)*: A new array of property values.
  450. * * *
  451. <!-- /div -->
  452. <!-- div -->
  453. ### <a id="benchmarkreducearray-callback-accumulator"></a>`Benchmark.reduce(array, callback, accumulator)`
  454. <a href="#benchmarkreducearray-callback-accumulator">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1885 "View in source") [&#x24C9;][1]
  455. A generic `Array#reduce` like method.
  456. #### Arguments
  457. 1. `array` *(Array)*: The array to iterate over.
  458. 2. `callback` *(Function)*: The function called per iteration.
  459. 3. `accumulator` *(Mixed)*: Initial value of the accumulator.
  460. #### Returns
  461. *(Mixed)*: The accumulator.
  462. * * *
  463. <!-- /div -->
  464. <!-- /div -->
  465. <!-- div -->
  466. ## `Benchmark.prototype`
  467. <!-- div -->
  468. ### <a id="benchmarkprototypeaborted"></a>`Benchmark.prototype.aborted`
  469. <a href="#benchmarkprototypeaborted">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3377 "View in source") [&#x24C9;][1]
  470. *(Boolean)*: A flag to indicate if the benchmark is aborted.
  471. * * *
  472. <!-- /div -->
  473. <!-- div -->
  474. ### <a id="benchmarkprototypecompiled"></a>`Benchmark.prototype.compiled`
  475. <a href="#benchmarkprototypecompiled">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3353 "View in source") [&#x24C9;][1]
  476. *(Function, String)*: The compiled test function.
  477. * * *
  478. <!-- /div -->
  479. <!-- div -->
  480. ### <a id="benchmarkprototypecount"></a>`Benchmark.prototype.count`
  481. <a href="#benchmarkprototypecount">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3329 "View in source") [&#x24C9;][1]
  482. *(Number)*: The number of times a test was executed.
  483. * * *
  484. <!-- /div -->
  485. <!-- div -->
  486. ### <a id="benchmarkprototypecycles"></a>`Benchmark.prototype.cycles`
  487. <a href="#benchmarkprototypecycles">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3337 "View in source") [&#x24C9;][1]
  488. *(Number)*: The number of cycles performed while benchmarking.
  489. * * *
  490. <!-- /div -->
  491. <!-- div -->
  492. ### <a id="benchmarkprototypefn"></a>`Benchmark.prototype.fn`
  493. <a href="#benchmarkprototypefn">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3369 "View in source") [&#x24C9;][1]
  494. *(Function, String)*: The test to benchmark.
  495. * * *
  496. <!-- /div -->
  497. <!-- div -->
  498. ### <a id="benchmarkprototypehz"></a>`Benchmark.prototype.hz`
  499. <a href="#benchmarkprototypehz">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3345 "View in source") [&#x24C9;][1]
  500. *(Number)*: The number of executions per second.
  501. * * *
  502. <!-- /div -->
  503. <!-- div -->
  504. ### <a id="benchmarkprototyperunning"></a>`Benchmark.prototype.running`
  505. <a href="#benchmarkprototyperunning">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3385 "View in source") [&#x24C9;][1]
  506. *(Boolean)*: A flag to indicate if the benchmark is running.
  507. * * *
  508. <!-- /div -->
  509. <!-- div -->
  510. ### <a id="benchmarkprototypesetup"></a>`Benchmark.prototype.setup`
  511. <a href="#benchmarkprototypesetup">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3448 "View in source") [&#x24C9;][1]
  512. *(Function, String)*: Compiled into the test and executed immediately **before** the test loop.
  513. #### Example
  514. ~~~ js
  515. // basic usage
  516. var bench = Benchmark({
  517. 'setup': function() {
  518. var c = this.count,
  519. element = document.getElementById('container');
  520. while (c--) {
  521. element.appendChild(document.createElement('div'));
  522. }
  523. },
  524. 'fn': function() {
  525. element.removeChild(element.lastChild);
  526. }
  527. });
  528. // compiles to something like:
  529. var c = this.count,
  530. element = document.getElementById('container');
  531. while (c--) {
  532. element.appendChild(document.createElement('div'));
  533. }
  534. var start = new Date;
  535. while (count--) {
  536. element.removeChild(element.lastChild);
  537. }
  538. var end = new Date - start;
  539. // or using strings
  540. var bench = Benchmark({
  541. 'setup': '\
  542. var a = 0;\n\
  543. (function() {\n\
  544. (function() {\n\
  545. (function() {',
  546. 'fn': 'a += 1;',
  547. 'teardown': '\
  548. }())\n\
  549. }())\n\
  550. }())'
  551. });
  552. // compiles to something like:
  553. var a = 0;
  554. (function() {
  555. (function() {
  556. (function() {
  557. var start = new Date;
  558. while (count--) {
  559. a += 1;
  560. }
  561. var end = new Date - start;
  562. }())
  563. }())
  564. }())
  565. ~~~
  566. * * *
  567. <!-- /div -->
  568. <!-- div -->
  569. ### <a id="benchmarkprototypeteardown"></a>`Benchmark.prototype.teardown`
  570. <a href="#benchmarkprototypeteardown">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3456 "View in source") [&#x24C9;][1]
  571. *(Function, String)*: Compiled into the test and executed immediately **after** the test loop.
  572. * * *
  573. <!-- /div -->
  574. <!-- div -->
  575. ### <a id="benchmarkprototypeabort"></a>`Benchmark.prototype.abort()`
  576. <a href="#benchmarkprototypeabort">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2218 "View in source") [&#x24C9;][1]
  577. Aborts the benchmark without recording times.
  578. #### Returns
  579. *(Object)*: The benchmark instance.
  580. * * *
  581. <!-- /div -->
  582. <!-- div -->
  583. ### <a id="benchmarkprototypecloneoptions"></a>`Benchmark.prototype.clone(options)`
  584. <a href="#benchmarkprototypecloneoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2257 "View in source") [&#x24C9;][1]
  585. Creates a new benchmark using the same test and options.
  586. #### Arguments
  587. 1. `options` *(Object)*: Options object to overwrite cloned options.
  588. #### Returns
  589. *(Object)*: The new benchmark instance.
  590. #### Example
  591. ~~~ js
  592. var bizarro = bench.clone({
  593. 'name': 'doppelganger'
  594. });
  595. ~~~
  596. * * *
  597. <!-- /div -->
  598. <!-- div -->
  599. ### <a id="benchmarkprototypecompareother"></a>`Benchmark.prototype.compare(other)`
  600. <a href="#benchmarkprototypecompareother">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2280 "View in source") [&#x24C9;][1]
  601. Determines if a benchmark is faster than another.
  602. #### Arguments
  603. 1. `other` *(Object)*: The benchmark to compare.
  604. #### Returns
  605. *(Number)*: Returns `-1` if slower, `1` if faster, and `0` if indeterminate.
  606. * * *
  607. <!-- /div -->
  608. <!-- div -->
  609. ### <a id="benchmarkprototypeemittype"></a>`Benchmark.Suite.prototype.emit(type)`
  610. <a href="#benchmarkprototypeemittype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [&#x24C9;][1]
  611. Executes all registered listeners of the specified event type.
  612. #### Arguments
  613. 1. `type` *(String|Object)*: The event type or object.
  614. #### Returns
  615. *(Mixed)*: Returns the return value of the last listener executed.
  616. * * *
  617. <!-- /div -->
  618. <!-- div -->
  619. ### <a id="benchmarkprototypelistenerstype"></a>`Benchmark.Suite.prototype.listeners(type)`
  620. <a href="#benchmarkprototypelistenerstype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [&#x24C9;][1]
  621. Returns an array of event listeners for a given type that can be manipulated to add or remove listeners.
  622. #### Arguments
  623. 1. `type` *(String)*: The event type.
  624. #### Returns
  625. *(Array)*: The listeners array.
  626. * * *
  627. <!-- /div -->
  628. <!-- div -->
  629. ### <a id="benchmarkprototypeofftype-listener"></a>`Benchmark.Suite.prototype.off([type, listener])`
  630. <a href="#benchmarkprototypeofftype-listener">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [&#x24C9;][1]
  631. 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.
  632. #### Arguments
  633. 1. `[type]` *(String)*: The event type.
  634. 2. `[listener]` *(Function)*: The function to unregister.
  635. #### Returns
  636. *(Object)*: The benchmark instance.
  637. #### Example
  638. ~~~ js
  639. // unregister a listener for an event type
  640. bench.off('cycle', listener);
  641. // unregister a listener for multiple event types
  642. bench.off('start cycle', listener);
  643. // unregister all listeners for an event type
  644. bench.off('cycle');
  645. // unregister all listeners for multiple event types
  646. bench.off('start cycle complete');
  647. // unregister all listeners for all event types
  648. bench.off();
  649. ~~~
  650. * * *
  651. <!-- /div -->
  652. <!-- div -->
  653. ### <a id="benchmarkprototypeontype-listener"></a>`Benchmark.Suite.prototype.on(type, listener)`
  654. <a href="#benchmarkprototypeontype-listener">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [&#x24C9;][1]
  655. Registers a listener for the specified event type(s).
  656. #### Arguments
  657. 1. `type` *(String)*: The event type.
  658. 2. `listener` *(Function)*: The function to register.
  659. #### Returns
  660. *(Object)*: The benchmark instance.
  661. #### Example
  662. ~~~ js
  663. // register a listener for an event type
  664. bench.on('cycle', listener);
  665. // register a listener for multiple event types
  666. bench.on('start cycle', listener);
  667. ~~~
  668. * * *
  669. <!-- /div -->
  670. <!-- div -->
  671. ### <a id="benchmarkprototypereset"></a>`Benchmark.prototype.reset()`
  672. <a href="#benchmarkprototypereset">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2334 "View in source") [&#x24C9;][1]
  673. Reset properties and abort if running.
  674. #### Returns
  675. *(Object)*: The benchmark instance.
  676. * * *
  677. <!-- /div -->
  678. <!-- div -->
  679. ### <a id="benchmarkprototyperunoptions"></a>`Benchmark.prototype.run([options={}])`
  680. <a href="#benchmarkprototyperunoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3000 "View in source") [&#x24C9;][1]
  681. Runs the benchmark.
  682. #### Arguments
  683. 1. `[options={}]` *(Object)*: Options object.
  684. #### Returns
  685. *(Object)*: The benchmark instance.
  686. #### Example
  687. ~~~ js
  688. // basic usage
  689. bench.run();
  690. // or with options
  691. bench.run({ 'async': true });
  692. ~~~
  693. * * *
  694. <!-- /div -->
  695. <!-- div -->
  696. ### <a id="benchmarkprototypetostring"></a>`Benchmark.prototype.toString()`
  697. <a href="#benchmarkprototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2405 "View in source") [&#x24C9;][1]
  698. Displays relevant benchmark information when coerced to a string.
  699. #### Returns
  700. *(String)*: A string representation of the benchmark instance.
  701. * * *
  702. <!-- /div -->
  703. <!-- /div -->
  704. <!-- div -->
  705. ## `Benchmark.options`
  706. <!-- div -->
  707. ### <a id="benchmarkoptions"></a>`Benchmark.options`
  708. <a href="#benchmarkoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3049 "View in source") [&#x24C9;][1]
  709. *(Object)*: The default options copied by benchmark instances.
  710. * * *
  711. <!-- /div -->
  712. <!-- div -->
  713. ### <a id="benchmarkoptionsasync"></a>`Benchmark.options.async`
  714. <a href="#benchmarkoptionsasync">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3058 "View in source") [&#x24C9;][1]
  715. *(Boolean)*: A flag to indicate that benchmark cycles will execute asynchronously by default.
  716. * * *
  717. <!-- /div -->
  718. <!-- div -->
  719. ### <a id="benchmarkoptionsdefer"></a>`Benchmark.options.defer`
  720. <a href="#benchmarkoptionsdefer">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3066 "View in source") [&#x24C9;][1]
  721. *(Boolean)*: A flag to indicate that the benchmark clock is deferred.
  722. * * *
  723. <!-- /div -->
  724. <!-- div -->
  725. ### <a id="benchmarkoptionsdelay"></a>`Benchmark.options.delay`
  726. <a href="#benchmarkoptionsdelay">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3073 "View in source") [&#x24C9;][1]
  727. *(Number)*: The delay between test cycles *(secs)*.
  728. * * *
  729. <!-- /div -->
  730. <!-- div -->
  731. ### <a id="benchmarkoptionsid"></a>`Benchmark.options.id`
  732. <a href="#benchmarkoptionsid">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3082 "View in source") [&#x24C9;][1]
  733. *(String)*: Displayed by Benchmark#toString when a `name` is not available *(auto-generated if absent)*.
  734. * * *
  735. <!-- /div -->
  736. <!-- div -->
  737. ### <a id="benchmarkoptionsinitcount"></a>`Benchmark.options.initCount`
  738. <a href="#benchmarkoptionsinitcount">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3090 "View in source") [&#x24C9;][1]
  739. *(Number)*: The default number of times to execute a test on a benchmark's first cycle.
  740. * * *
  741. <!-- /div -->
  742. <!-- div -->
  743. ### <a id="benchmarkoptionsmaxtime"></a>`Benchmark.options.maxTime`
  744. <a href="#benchmarkoptionsmaxtime">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3099 "View in source") [&#x24C9;][1]
  745. *(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*. Note: Cycle delays aren't counted toward the maximum time.
  746. * * *
  747. <!-- /div -->
  748. <!-- div -->
  749. ### <a id="benchmarkoptionsminsamples"></a>`Benchmark.options.minSamples`
  750. <a href="#benchmarkoptionsminsamples">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3107 "View in source") [&#x24C9;][1]
  751. *(Number)*: The minimum sample size required to perform statistical analysis.
  752. * * *
  753. <!-- /div -->
  754. <!-- div -->
  755. ### <a id="benchmarkoptionsmintime"></a>`Benchmark.options.minTime`
  756. <a href="#benchmarkoptionsmintime">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3115 "View in source") [&#x24C9;][1]
  757. *(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*.
  758. * * *
  759. <!-- /div -->
  760. <!-- div -->
  761. ### <a id="benchmarkoptionsname"></a>`Benchmark.options.name`
  762. <a href="#benchmarkoptionsname">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3123 "View in source") [&#x24C9;][1]
  763. *(String)*: The name of the benchmark.
  764. * * *
  765. <!-- /div -->
  766. <!-- div -->
  767. ### <a id="benchmarkoptionsonabort"></a>`Benchmark.options.onAbort`
  768. <a href="#benchmarkoptionsonabort">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3131 "View in source") [&#x24C9;][1]
  769. An event listener called when the benchmark is aborted.
  770. * * *
  771. <!-- /div -->
  772. <!-- div -->
  773. ### <a id="benchmarkoptionsoncomplete"></a>`Benchmark.options.onComplete`
  774. <a href="#benchmarkoptionsoncomplete">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3139 "View in source") [&#x24C9;][1]
  775. An event listener called when the benchmark completes running.
  776. * * *
  777. <!-- /div -->
  778. <!-- div -->
  779. ### <a id="benchmarkoptionsoncycle"></a>`Benchmark.options.onCycle`
  780. <a href="#benchmarkoptionsoncycle">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3147 "View in source") [&#x24C9;][1]
  781. An event listener called after each run cycle.
  782. * * *
  783. <!-- /div -->
  784. <!-- div -->
  785. ### <a id="benchmarkoptionsonerror"></a>`Benchmark.options.onError`
  786. <a href="#benchmarkoptionsonerror">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3155 "View in source") [&#x24C9;][1]
  787. An event listener called when a test errors.
  788. * * *
  789. <!-- /div -->
  790. <!-- div -->
  791. ### <a id="benchmarkoptionsonreset"></a>`Benchmark.options.onReset`
  792. <a href="#benchmarkoptionsonreset">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3163 "View in source") [&#x24C9;][1]
  793. An event listener called when the benchmark is reset.
  794. * * *
  795. <!-- /div -->
  796. <!-- div -->
  797. ### <a id="benchmarkoptionsonstart"></a>`Benchmark.options.onStart`
  798. <a href="#benchmarkoptionsonstart">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3171 "View in source") [&#x24C9;][1]
  799. An event listener called when the benchmark starts running.
  800. * * *
  801. <!-- /div -->
  802. <!-- /div -->
  803. <!-- div -->
  804. ## `Benchmark.platform`
  805. <!-- div -->
  806. ### <a id="benchmarkplatform"></a>`Benchmark.platform`
  807. <a href="#benchmarkplatform">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3182 "View in source") [&#x24C9;][1]
  808. *(Object)*: Platform object with properties describing things like browser name, version, and operating system.
  809. * * *
  810. <!-- /div -->
  811. <!-- div -->
  812. ### <a id="benchmarkplatformdescription"></a>`Benchmark.platform.description`
  813. <a href="#benchmarkplatformdescription">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3190 "View in source") [&#x24C9;][1]
  814. *(String)*: The platform description.
  815. * * *
  816. <!-- /div -->
  817. <!-- div -->
  818. ### <a id="benchmarkplatformlayout"></a>`Benchmark.platform.layout`
  819. <a href="#benchmarkplatformlayout">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3198 "View in source") [&#x24C9;][1]
  820. *(String, Null)*: The name of the browser layout engine.
  821. * * *
  822. <!-- /div -->
  823. <!-- div -->
  824. ### <a id="benchmarkplatformmanufacturer"></a>`Benchmark.platform.manufacturer`
  825. <a href="#benchmarkplatformmanufacturer">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3222 "View in source") [&#x24C9;][1]
  826. *(String, Null)*: The name of the product's manufacturer.
  827. * * *
  828. <!-- /div -->
  829. <!-- div -->
  830. ### <a id="benchmarkplatformname"></a>`Benchmark.platform.name`
  831. <a href="#benchmarkplatformname">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3214 "View in source") [&#x24C9;][1]
  832. *(String, Null)*: The name of the browser/environment.
  833. * * *
  834. <!-- /div -->
  835. <!-- div -->
  836. ### <a id="benchmarkplatformos"></a>`Benchmark.platform.os`
  837. <a href="#benchmarkplatformos">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3230 "View in source") [&#x24C9;][1]
  838. *(String, Null)*: The name of the operating system.
  839. * * *
  840. <!-- /div -->
  841. <!-- div -->
  842. ### <a id="benchmarkplatformprerelease"></a>`Benchmark.platform.prerelease`
  843. <a href="#benchmarkplatformprerelease">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3238 "View in source") [&#x24C9;][1]
  844. *(String, Null)*: The alpha/beta release indicator.
  845. * * *
  846. <!-- /div -->
  847. <!-- div -->
  848. ### <a id="benchmarkplatformproduct"></a>`Benchmark.platform.product`
  849. <a href="#benchmarkplatformproduct">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3206 "View in source") [&#x24C9;][1]
  850. *(String, Null)*: The name of the product hosting the browser.
  851. * * *
  852. <!-- /div -->
  853. <!-- div -->
  854. ### <a id="benchmarkplatformversion"></a>`Benchmark.platform.version`
  855. <a href="#benchmarkplatformversion">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3246 "View in source") [&#x24C9;][1]
  856. *(String, Null)*: The browser/environment version.
  857. * * *
  858. <!-- /div -->
  859. <!-- div -->
  860. ### <a id="benchmarkplatformtostring"></a>`Benchmark.platform.toString()`
  861. <a href="#benchmarkplatformtostring">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3255 "View in source") [&#x24C9;][1]
  862. Return platform description when the platform object is coerced to a string.
  863. #### Returns
  864. *(String)*: The platform description.
  865. * * *
  866. <!-- /div -->
  867. <!-- /div -->
  868. <!-- div -->
  869. ## `Benchmark.support`
  870. <!-- div -->
  871. ### <a id="benchmarksupport"></a>`Benchmark.support`
  872. <a href="#benchmarksupport">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L135 "View in source") [&#x24C9;][1]
  873. *(Object)*: An object used to flag environments/features.
  874. * * *
  875. <!-- /div -->
  876. <!-- div -->
  877. ### <a id="benchmarksupportair"></a>`Benchmark.support.air`
  878. <a href="#benchmarksupportair">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L145 "View in source") [&#x24C9;][1]
  879. *(Boolean)*: Detect Adobe AIR.
  880. * * *
  881. <!-- /div -->
  882. <!-- div -->
  883. ### <a id="benchmarksupportargumentsclass"></a>`Benchmark.support.argumentsClass`
  884. <a href="#benchmarksupportargumentsclass">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L153 "View in source") [&#x24C9;][1]
  885. *(Boolean)*: Detect if `arguments` objects have the correct internal [[Class]] value.
  886. * * *
  887. <!-- /div -->
  888. <!-- div -->
  889. ### <a id="benchmarksupportbrowser"></a>`Benchmark.support.browser`
  890. <a href="#benchmarksupportbrowser">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L161 "View in source") [&#x24C9;][1]
  891. *(Boolean)*: Detect if in a browser environment.
  892. * * *
  893. <!-- /div -->
  894. <!-- div -->
  895. ### <a id="benchmarksupportcharbyindex"></a>`Benchmark.support.charByIndex`
  896. <a href="#benchmarksupportcharbyindex">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L169 "View in source") [&#x24C9;][1]
  897. *(Boolean)*: Detect if strings support accessing characters by index.
  898. * * *
  899. <!-- /div -->
  900. <!-- div -->
  901. ### <a id="benchmarksupportcharbyownindex"></a>`Benchmark.support.charByOwnIndex`
  902. <a href="#benchmarksupportcharbyownindex">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L179 "View in source") [&#x24C9;][1]
  903. *(Boolean)*: Detect if strings have indexes as own properties.
  904. * * *
  905. <!-- /div -->
  906. <!-- div -->
  907. ### <a id="benchmarksupportdecompilation"></a>`Benchmark.support.decompilation`
  908. <a href="#benchmarksupportdecompilation">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L207 "View in source") [&#x24C9;][1]
  909. *(Boolean)*: Detect if functions support decompilation.
  910. * * *
  911. <!-- /div -->
  912. <!-- div -->
  913. ### <a id="benchmarksupportdescriptors"></a>`Benchmark.support.descriptors`
  914. <a href="#benchmarksupportdescriptors">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L228 "View in source") [&#x24C9;][1]
  915. *(Boolean)*: Detect ES5+ property descriptor API.
  916. * * *
  917. <!-- /div -->
  918. <!-- div -->
  919. ### <a id="benchmarksupportgetallkeys"></a>`Benchmark.support.getAllKeys`
  920. <a href="#benchmarksupportgetallkeys">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L242 "View in source") [&#x24C9;][1]
  921. *(Boolean)*: Detect ES5+ Object.getOwnPropertyNames().
  922. * * *
  923. <!-- /div -->
  924. <!-- div -->
  925. ### <a id="benchmarksupportiteratesownfirst"></a>`Benchmark.support.iteratesOwnFirst`
  926. <a href="#benchmarksupportiteratesownfirst">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L255 "View in source") [&#x24C9;][1]
  927. *(Boolean)*: Detect if own properties are iterated before inherited properties *(all but IE < `9`)*.
  928. * * *
  929. <!-- /div -->
  930. <!-- div -->
  931. ### <a id="benchmarksupportjava"></a>`Benchmark.support.java`
  932. <a href="#benchmarksupportjava">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L190 "View in source") [&#x24C9;][1]
  933. *(Boolean)*: Detect if Java is enabled/exposed.
  934. * * *
  935. <!-- /div -->
  936. <!-- div -->
  937. ### <a id="benchmarksupportnodeclass"></a>`Benchmark.support.nodeClass`
  938. <a href="#benchmarksupportnodeclass">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L272 "View in source") [&#x24C9;][1]
  939. *(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".
  940. * * *
  941. <!-- /div -->
  942. <!-- div -->
  943. ### <a id="benchmarksupporttimeout"></a>`Benchmark.support.timeout`
  944. <a href="#benchmarksupporttimeout">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L198 "View in source") [&#x24C9;][1]
  945. *(Boolean)*: Detect if the Timers API exists.
  946. * * *
  947. <!-- /div -->
  948. <!-- /div -->
  949. <!-- div -->
  950. ## `Benchmark.prototype.error`
  951. <!-- div -->
  952. ### <a id="benchmarkprototypeerror"></a>`Benchmark.prototype.error`
  953. <a href="#benchmarkprototypeerror">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3361 "View in source") [&#x24C9;][1]
  954. *(Object)*: The error object if the test failed.
  955. * * *
  956. <!-- /div -->
  957. <!-- /div -->
  958. <!-- div -->
  959. ## `Benchmark.prototype.stats`
  960. <!-- div -->
  961. ### <a id="benchmarkprototypestats"></a>`Benchmark.prototype.stats`
  962. <a href="#benchmarkprototypestats">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3464 "View in source") [&#x24C9;][1]
  963. *(Object)*: An object of stats including mean, margin or error, and standard deviation.
  964. * * *
  965. <!-- /div -->
  966. <!-- div -->
  967. ### <a id="benchmark-statsdeviation"></a>`Benchmark.prototype.stats.deviation`
  968. <a href="#benchmark-statsdeviation">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3496 "View in source") [&#x24C9;][1]
  969. *(Number)*: The sample standard deviation.
  970. * * *
  971. <!-- /div -->
  972. <!-- div -->
  973. ### <a id="benchmark-statsmean"></a>`Benchmark.prototype.stats.mean`
  974. <a href="#benchmark-statsmean">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3504 "View in source") [&#x24C9;][1]
  975. *(Number)*: The sample arithmetic mean.
  976. * * *
  977. <!-- /div -->
  978. <!-- div -->
  979. ### <a id="benchmark-statsmoe"></a>`Benchmark.prototype.stats.moe`
  980. <a href="#benchmark-statsmoe">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3472 "View in source") [&#x24C9;][1]
  981. *(Number)*: The margin of error.
  982. * * *
  983. <!-- /div -->
  984. <!-- div -->
  985. ### <a id="benchmark-statsrme"></a>`Benchmark.prototype.stats.rme`
  986. <a href="#benchmark-statsrme">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3480 "View in source") [&#x24C9;][1]
  987. *(Number)*: The relative margin of error *(expressed as a percentage of the mean)*.
  988. * * *
  989. <!-- /div -->
  990. <!-- div -->
  991. ### <a id="benchmark-statssample"></a>`Benchmark.prototype.stats.sample`
  992. <a href="#benchmark-statssample">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3512 "View in source") [&#x24C9;][1]
  993. *(Array)*: The array of sampled periods.
  994. * * *
  995. <!-- /div -->
  996. <!-- div -->
  997. ### <a id="benchmark-statssem"></a>`Benchmark.prototype.stats.sem`
  998. <a href="#benchmark-statssem">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3488 "View in source") [&#x24C9;][1]
  999. *(Number)*: The standard error of the mean.
  1000. * * *
  1001. <!-- /div -->
  1002. <!-- div -->
  1003. ### <a id="benchmark-statsvariance"></a>`Benchmark.prototype.stats.variance`
  1004. <a href="#benchmark-statsvariance">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3520 "View in source") [&#x24C9;][1]
  1005. *(Number)*: The sample variance.
  1006. * * *
  1007. <!-- /div -->
  1008. <!-- /div -->
  1009. <!-- div -->
  1010. ## `Benchmark.prototype.times`
  1011. <!-- div -->
  1012. ### <a id="benchmarkprototypetimes"></a>`Benchmark.prototype.times`
  1013. <a href="#benchmarkprototypetimes">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3529 "View in source") [&#x24C9;][1]
  1014. *(Object)*: An object of timing data including cycle, elapsed, period, start, and stop.
  1015. * * *
  1016. <!-- /div -->
  1017. <!-- div -->
  1018. ### <a id="benchmark-timescycle"></a>`Benchmark.prototype.times.cycle`
  1019. <a href="#benchmark-timescycle">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3537 "View in source") [&#x24C9;][1]
  1020. *(Number)*: The time taken to complete the last cycle *(secs)*.
  1021. * * *
  1022. <!-- /div -->
  1023. <!-- div -->
  1024. ### <a id="benchmark-timeselapsed"></a>`Benchmark.prototype.times.elapsed`
  1025. <a href="#benchmark-timeselapsed">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3545 "View in source") [&#x24C9;][1]
  1026. *(Number)*: The time taken to complete the benchmark *(secs)*.
  1027. * * *
  1028. <!-- /div -->
  1029. <!-- div -->
  1030. ### <a id="benchmark-timesperiod"></a>`Benchmark.prototype.times.period`
  1031. <a href="#benchmark-timesperiod">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3553 "View in source") [&#x24C9;][1]
  1032. *(Number)*: The time taken to execute the test once *(secs)*.
  1033. * * *
  1034. <!-- /div -->
  1035. <!-- div -->
  1036. ### <a id="benchmark-timestimestamp"></a>`Benchmark.prototype.times.timeStamp`
  1037. <a href="#benchmark-timestimestamp">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3561 "View in source") [&#x24C9;][1]
  1038. *(Number)*: A timestamp of when the benchmark started *(ms)*.
  1039. * * *
  1040. <!-- /div -->
  1041. <!-- /div -->
  1042. <!-- div -->
  1043. ## `Benchmark.Deferred`
  1044. <!-- div -->
  1045. ### <a id="benchmarkdeferredclone"></a>`Benchmark.Deferred(clone)`
  1046. <a href="#benchmarkdeferredclone">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L445 "View in source") [&#x24C9;][1]
  1047. The Deferred constructor.
  1048. #### Arguments
  1049. 1. `clone` *(Object)*: The cloned benchmark instance.
  1050. * * *
  1051. <!-- /div -->
  1052. <!-- /div -->
  1053. <!-- div -->
  1054. ## `Benchmark.Deferred.prototype`
  1055. <!-- div -->
  1056. ### <a id="benchmarkdeferredprototypebenchmark"></a>`Benchmark.Deferred.prototype.benchmark`
  1057. <a href="#benchmarkdeferredprototypebenchmark">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3605 "View in source") [&#x24C9;][1]
  1058. *(Object)*: The deferred benchmark instance.
  1059. * * *
  1060. <!-- /div -->
  1061. <!-- div -->
  1062. ### <a id="benchmarkdeferredprototypecycles"></a>`Benchmark.Deferred.prototype.cycles`
  1063. <a href="#benchmarkdeferredprototypecycles">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3613 "View in source") [&#x24C9;][1]
  1064. *(Number)*: The number of deferred cycles performed while benchmarking.
  1065. * * *
  1066. <!-- /div -->
  1067. <!-- div -->
  1068. ### <a id="benchmarkdeferredprototypeelapsed"></a>`Benchmark.Deferred.prototype.elapsed`
  1069. <a href="#benchmarkdeferredprototypeelapsed">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3621 "View in source") [&#x24C9;][1]
  1070. *(Number)*: The time taken to complete the deferred benchmark *(secs)*.
  1071. * * *
  1072. <!-- /div -->
  1073. <!-- div -->
  1074. ### <a id="benchmarkdeferredprototyperesolve"></a>`Benchmark.Deferred.prototype.resolve`
  1075. <a href="#benchmarkdeferredprototyperesolve">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1188 "View in source") [&#x24C9;][1]
  1076. *(Unknown)*: Handles cycling/completing the deferred benchmark.
  1077. * * *
  1078. <!-- /div -->
  1079. <!-- div -->
  1080. ### <a id="benchmarkdeferredprototypetimestamp"></a>`Benchmark.Deferred.prototype.timeStamp`
  1081. <a href="#benchmarkdeferredprototypetimestamp">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3629 "View in source") [&#x24C9;][1]
  1082. *(Number)*: A timestamp of when the deferred benchmark started *(ms)*.
  1083. * * *
  1084. <!-- /div -->
  1085. <!-- /div -->
  1086. <!-- div -->
  1087. ## `Benchmark.Event`
  1088. <!-- div -->
  1089. ### <a id="benchmarkeventtype"></a>`Benchmark.Event(type)`
  1090. <a href="#benchmarkeventtype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L461 "View in source") [&#x24C9;][1]
  1091. The Event constructor.
  1092. #### Arguments
  1093. 1. `type` *(String|Object)*: The event type.
  1094. * * *
  1095. <!-- /div -->
  1096. <!-- /div -->
  1097. <!-- div -->
  1098. ## `Benchmark.Event.prototype`
  1099. <!-- div -->
  1100. ### <a id="benchmarkeventprototypeaborted"></a>`Benchmark.Event.prototype.aborted`
  1101. <a href="#benchmarkeventprototypeaborted">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3645 "View in source") [&#x24C9;][1]
  1102. *(Boolean)*: A flag to indicate if the emitters listener iteration is aborted.
  1103. * * *
  1104. <!-- /div -->
  1105. <!-- div -->
  1106. ### <a id="benchmarkeventprototypecancelled"></a>`Benchmark.Event.prototype.cancelled`
  1107. <a href="#benchmarkeventprototypecancelled">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3653 "View in source") [&#x24C9;][1]
  1108. *(Boolean)*: A flag to indicate if the default action is cancelled.
  1109. * * *
  1110. <!-- /div -->
  1111. <!-- div -->
  1112. ### <a id="benchmarkeventprototyperesult"></a>`Benchmark.Event.prototype.result`
  1113. <a href="#benchmarkeventprototyperesult">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3669 "View in source") [&#x24C9;][1]
  1114. *(Mixed)*: The return value of the last executed listener.
  1115. * * *
  1116. <!-- /div -->
  1117. <!-- div -->
  1118. ### <a id="benchmarkeventprototypetimestamp"></a>`Benchmark.Event.prototype.timeStamp`
  1119. <a href="#benchmarkeventprototypetimestamp">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3685 "View in source") [&#x24C9;][1]
  1120. *(Number)*: A timestamp of when the event was created *(ms)*.
  1121. * * *
  1122. <!-- /div -->
  1123. <!-- div -->
  1124. ### <a id="benchmarkeventprototypetype"></a>`Benchmark.Event.prototype.type`
  1125. <a href="#benchmarkeventprototypetype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3693 "View in source") [&#x24C9;][1]
  1126. *(String)*: The event type.
  1127. * * *
  1128. <!-- /div -->
  1129. <!-- /div -->
  1130. <!-- div -->
  1131. ## `Benchmark.Event.prototype.currentTarget`
  1132. <!-- div -->
  1133. ### <a id="benchmarkeventprototypecurrenttarget"></a>`Benchmark.Event.prototype.currentTarget`
  1134. <a href="#benchmarkeventprototypecurrenttarget">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3661 "View in source") [&#x24C9;][1]
  1135. *(Object)*: The object whose listeners are currently being processed.
  1136. * * *
  1137. <!-- /div -->
  1138. <!-- /div -->
  1139. <!-- div -->
  1140. ## `Benchmark.Event.prototype.target`
  1141. <!-- div -->
  1142. ### <a id="benchmarkeventprototypetarget"></a>`Benchmark.Event.prototype.target`
  1143. <a href="#benchmarkeventprototypetarget">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3677 "View in source") [&#x24C9;][1]
  1144. *(Object)*: The object to which the event was originally emitted.
  1145. * * *
  1146. <!-- /div -->
  1147. <!-- /div -->
  1148. <!-- div -->
  1149. ## `Benchmark.Suite`
  1150. <!-- div -->
  1151. ### <a id="benchmarksuitename--options"></a>`Benchmark.Suite(name [, options={}])`
  1152. <a href="#benchmarksuitename--options">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L507 "View in source") [&#x24C9;][1]
  1153. The Suite constructor.
  1154. #### Arguments
  1155. 1. `name` *(String)*: A name to identify the suite.
  1156. 2. `[options={}]` *(Object)*: Options object.
  1157. #### Example
  1158. ~~~ js
  1159. // basic usage (the `new` operator is optional)
  1160. var suite = new Benchmark.Suite;
  1161. // or using a name first
  1162. var suite = new Benchmark.Suite('foo');
  1163. // or with options
  1164. var suite = new Benchmark.Suite('foo', {
  1165. // called when the suite starts running
  1166. 'onStart': onStart,
  1167. // called between running benchmarks
  1168. 'onCycle': onCycle,
  1169. // called when aborted
  1170. 'onAbort': onAbort,
  1171. // called when a test errors
  1172. 'onError': onError,
  1173. // called when reset
  1174. 'onReset': onReset,
  1175. // called when the suite completes running
  1176. 'onComplete': onComplete
  1177. });
  1178. ~~~
  1179. * * *
  1180. <!-- /div -->
  1181. <!-- /div -->
  1182. <!-- div -->
  1183. ## `Benchmark.Suite.prototype`
  1184. <!-- div -->
  1185. ### <a id="benchmarksuiteprototypeaborted"></a>`Benchmark.Suite.prototype.aborted`
  1186. <a href="#benchmarksuiteprototypeaborted">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3734 "View in source") [&#x24C9;][1]
  1187. *(Boolean)*: A flag to indicate if the suite is aborted.
  1188. * * *
  1189. <!-- /div -->
  1190. <!-- div -->
  1191. ### <a id="benchmarksuiteprototypelength"></a>`Benchmark.Suite.prototype.length`
  1192. <a href="#benchmarksuiteprototypelength">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3726 "View in source") [&#x24C9;][1]
  1193. *(Number)*: The number of benchmarks in the suite.
  1194. * * *
  1195. <!-- /div -->
  1196. <!-- div -->
  1197. ### <a id="benchmarksuiteprototyperunning"></a>`Benchmark.Suite.prototype.running`
  1198. <a href="#benchmarksuiteprototyperunning">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3742 "View in source") [&#x24C9;][1]
  1199. *(Boolean)*: A flag to indicate if the suite is running.
  1200. * * *
  1201. <!-- /div -->
  1202. <!-- div -->
  1203. ### <a id="benchmarksuiteprototypeabort"></a>`Benchmark.Suite.prototype.abort()`
  1204. <a href="#benchmarksuiteprototypeabort">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1902 "View in source") [&#x24C9;][1]
  1205. Aborts all benchmarks in the suite.
  1206. #### Returns
  1207. *(Object)*: The suite instance.
  1208. * * *
  1209. <!-- /div -->
  1210. <!-- div -->
  1211. ### <a id="benchmarksuiteprototypeaddname-fn--options"></a>`Benchmark.Suite.prototype.add(name, fn [, options={}])`
  1212. <a href="#benchmarksuiteprototypeaddname-fn--options">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1962 "View in source") [&#x24C9;][1]
  1213. Adds a test to the benchmark suite.
  1214. #### Arguments
  1215. 1. `name` *(String)*: A name to identify the benchmark.
  1216. 2. `fn` *(Function|String)*: The test to benchmark.
  1217. 3. `[options={}]` *(Object)*: Options object.
  1218. #### Returns
  1219. *(Object)*: The benchmark instance.
  1220. #### Example
  1221. ~~~ js
  1222. // basic usage
  1223. suite.add(fn);
  1224. // or using a name first
  1225. suite.add('foo', fn);
  1226. // or with options
  1227. suite.add('foo', fn, {
  1228. 'onCycle': onCycle,
  1229. 'onComplete': onComplete
  1230. });
  1231. // or name and options
  1232. suite.add('foo', {
  1233. 'fn': fn,
  1234. 'onCycle': onCycle,
  1235. 'onComplete': onComplete
  1236. });
  1237. // or options only
  1238. suite.add({
  1239. 'name': 'foo',
  1240. 'fn': fn,
  1241. 'onCycle': onCycle,
  1242. 'onComplete': onComplete
  1243. });
  1244. ~~~
  1245. * * *
  1246. <!-- /div -->
  1247. <!-- div -->
  1248. ### <a id="benchmarksuiteprototypecloneoptions"></a>`Benchmark.Suite.prototype.clone(options)`
  1249. <a href="#benchmarksuiteprototypecloneoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1981 "View in source") [&#x24C9;][1]
  1250. Creates a new suite with cloned benchmarks.
  1251. #### Arguments
  1252. 1. `options` *(Object)*: Options object to overwrite cloned options.
  1253. #### Returns
  1254. *(Object)*: The new suite instance.
  1255. * * *
  1256. <!-- /div -->
  1257. <!-- div -->
  1258. ### <a id="benchmarkprototypeemittype"></a>`Benchmark.Suite.prototype.emit(type)`
  1259. <a href="#benchmarkprototypeemittype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [&#x24C9;][1]
  1260. Executes all registered listeners of the specified event type.
  1261. #### Arguments
  1262. 1. `type` *(String|Object)*: The event type or object.
  1263. #### Returns
  1264. *(Mixed)*: Returns the return value of the last listener executed.
  1265. * * *
  1266. <!-- /div -->
  1267. <!-- div -->
  1268. ### <a id="benchmarksuiteprototypefiltercallback"></a>`Benchmark.Suite.prototype.filter(callback)`
  1269. <a href="#benchmarksuiteprototypefiltercallback">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2004 "View in source") [&#x24C9;][1]
  1270. An `Array#filter` like method.
  1271. #### Arguments
  1272. 1. `callback` *(Function|String)*: The function/alias called per iteration.
  1273. #### Returns
  1274. *(Object)*: A new suite of benchmarks that passed callback filter.
  1275. * * *
  1276. <!-- /div -->
  1277. <!-- div -->
  1278. ### <a id="benchmarksuiteprototypeforeachcallback"></a>`Benchmark.Suite.prototype.forEach(callback)`
  1279. <a href="#benchmarksuiteprototypeforeachcallback">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3752 "View in source") [&#x24C9;][1]
  1280. An `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`.
  1281. #### Arguments
  1282. 1. `callback` *(Function)*: The function called per iteration.
  1283. #### Returns
  1284. *(Object)*: The suite iterated over.
  1285. * * *
  1286. <!-- /div -->
  1287. <!-- div -->
  1288. ### <a id="benchmarksuiteprototypeindexofvalue"></a>`Benchmark.Suite.prototype.indexOf(value)`
  1289. <a href="#benchmarksuiteprototypeindexofvalue">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3761 "View in source") [&#x24C9;][1]
  1290. An `Array#indexOf` like method.
  1291. #### Arguments
  1292. 1. `value` *(Mixed)*: The value to search for.
  1293. #### Returns
  1294. *(Number)*: The index of the matched value or `-1`.
  1295. * * *
  1296. <!-- /div -->
  1297. <!-- div -->
  1298. ### <a id="benchmarksuiteprototypeinvokename--arg1-arg2-"></a>`Benchmark.Suite.prototype.invoke(name [, arg1, arg2, ...])`
  1299. <a href="#benchmarksuiteprototypeinvokename--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3771 "View in source") [&#x24C9;][1]
  1300. Invokes a method on all benchmarks in the suite.
  1301. #### Arguments
  1302. 1. `name` *(String|Object)*: The name of the method to invoke OR options object.
  1303. 2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
  1304. #### Returns
  1305. *(Array)*: A new array of values returned from each method invoked.
  1306. * * *
  1307. <!-- /div -->
  1308. <!-- div -->
  1309. ### <a id="benchmarksuiteprototypejoinseparator-"></a>`Benchmark.Suite.prototype.join([separator=','])`
  1310. <a href="#benchmarksuiteprototypejoinseparator-">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3780 "View in source") [&#x24C9;][1]
  1311. Converts the suite of benchmarks to a string.
  1312. #### Arguments
  1313. 1. `[separator=',']` *(String)*: A string to separate each element of the array.
  1314. #### Returns
  1315. *(String)*: The string.
  1316. * * *
  1317. <!-- /div -->
  1318. <!-- div -->
  1319. ### <a id="benchmarkprototypelistenerstype"></a>`Benchmark.Suite.prototype.listeners(type)`
  1320. <a href="#benchmarkprototypelistenerstype">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [&#x24C9;][1]
  1321. Returns an array of event listeners for a given type that can be manipulated to add or remove listeners.
  1322. #### Arguments
  1323. 1. `type` *(String)*: The event type.
  1324. #### Returns
  1325. *(Array)*: The listeners array.
  1326. * * *
  1327. <!-- /div -->
  1328. <!-- div -->
  1329. ### <a id="benchmarksuiteprototypemapcallback"></a>`Benchmark.Suite.prototype.map(callback)`
  1330. <a href="#benchmarksuiteprototypemapcallback">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3789 "View in source") [&#x24C9;][1]
  1331. An `Array#map` like method.
  1332. #### Arguments
  1333. 1. `callback` *(Function)*: The function called per iteration.
  1334. #### Returns
  1335. *(Array)*: A new array of values returned by the callback.
  1336. * * *
  1337. <!-- /div -->
  1338. <!-- div -->
  1339. ### <a id="benchmarkprototypeofftype-listener"></a>`Benchmark.Suite.prototype.off([type, listener])`
  1340. <a href="#benchmarkprototypeofftype-listener">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [&#x24C9;][1]
  1341. 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.
  1342. #### Arguments
  1343. 1. `[type]` *(String)*: The event type.
  1344. 2. `[listener]` *(Function)*: The function to unregister.
  1345. #### Returns
  1346. *(Object)*: The benchmark instance.
  1347. #### Example
  1348. ~~~ js
  1349. // unregister a listener for an event type
  1350. bench.off('cycle', listener);
  1351. // unregister a listener for multiple event types
  1352. bench.off('start cycle', listener);
  1353. // unregister all listeners for an event type
  1354. bench.off('cycle');
  1355. // unregister all listeners for multiple event types
  1356. bench.off('start cycle complete');
  1357. // unregister all listeners for all event types
  1358. bench.off();
  1359. ~~~
  1360. * * *
  1361. <!-- /div -->
  1362. <!-- div -->
  1363. ### <a id="benchmarkprototypeontype-listener"></a>`Benchmark.Suite.prototype.on(type, listener)`
  1364. <a href="#benchmarkprototypeontype-listener">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [&#x24C9;][1]
  1365. Registers a listener for the specified event type(s).
  1366. #### Arguments
  1367. 1. `type` *(String)*: The event type.
  1368. 2. `listener` *(Function)*: The function to register.
  1369. #### Returns
  1370. *(Object)*: The benchmark instance.
  1371. #### Example
  1372. ~~~ js
  1373. // register a listener for an event type
  1374. bench.on('cycle', listener);
  1375. // register a listener for multiple event types
  1376. bench.on('start cycle', listener);
  1377. ~~~
  1378. * * *
  1379. <!-- /div -->
  1380. <!-- div -->
  1381. ### <a id="benchmarksuiteprototypepluckproperty"></a>`Benchmark.Suite.prototype.pluck(property)`
  1382. <a href="#benchmarksuiteprototypepluckproperty">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3798 "View in source") [&#x24C9;][1]
  1383. Retrieves the value of a specified property from all benchmarks in the suite.
  1384. #### Arguments
  1385. 1. `property` *(String)*: The property to pluck.
  1386. #### Returns
  1387. *(Array)*: A new array of property values.
  1388. * * *
  1389. <!-- /div -->
  1390. <!-- div -->
  1391. ### <a id="benchmarksuiteprototypepop"></a>`Benchmark.Suite.prototype.pop()`
  1392. <a href="#benchmarksuiteprototypepop">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3806 "View in source") [&#x24C9;][1]
  1393. Removes the last benchmark from the suite and returns it.
  1394. #### Returns
  1395. *(Mixed)*: The removed benchmark.
  1396. * * *
  1397. <!-- /div -->
  1398. <!-- div -->
  1399. ### <a id="benchmarksuiteprototypepush"></a>`Benchmark.Suite.prototype.push()`
  1400. <a href="#benchmarksuiteprototypepush">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3814 "View in source") [&#x24C9;][1]
  1401. Appends benchmarks to the suite.
  1402. #### Returns
  1403. *(Number)*: The suite's new length.
  1404. * * *
  1405. <!-- /div -->
  1406. <!-- div -->
  1407. ### <a id="benchmarksuiteprototypereducecallback-accumulator"></a>`Benchmark.Suite.prototype.reduce(callback, accumulator)`
  1408. <a href="#benchmarksuiteprototypereducecallback-accumulator">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3833 "View in source") [&#x24C9;][1]
  1409. An `Array#reduce` like method.
  1410. #### Arguments
  1411. 1. `callback` *(Function)*: The function called per iteration.
  1412. 2. `accumulator` *(Mixed)*: Initial value of the accumulator.
  1413. #### Returns
  1414. *(Mixed)*: The accumulator.
  1415. * * *
  1416. <!-- /div -->
  1417. <!-- div -->
  1418. ### <a id="benchmarksuiteprototypereset"></a>`Benchmark.Suite.prototype.reset()`
  1419. <a href="#benchmarksuiteprototypereset">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2019 "View in source") [&#x24C9;][1]
  1420. Resets all benchmarks in the suite.
  1421. #### Returns
  1422. *(Object)*: The suite instance.
  1423. * * *
  1424. <!-- /div -->
  1425. <!-- div -->
  1426. ### <a id="benchmarksuiteprototypereverse"></a>`Benchmark.Suite.prototype.reverse()`
  1427. <a href="#benchmarksuiteprototypereverse">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L638 "View in source") [&#x24C9;][1]
  1428. Rearrange the host array's elements in reverse order.
  1429. #### Returns
  1430. *(Array)*: The reversed array.
  1431. * * *
  1432. <!-- /div -->
  1433. <!-- div -->
  1434. ### <a id="benchmarksuiteprototyperunoptions"></a>`Benchmark.Suite.prototype.run([options={}])`
  1435. <a href="#benchmarksuiteprototyperunoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2056 "View in source") [&#x24C9;][1]
  1436. Runs the suite.
  1437. #### Arguments
  1438. 1. `[options={}]` *(Object)*: Options object.
  1439. #### Returns
  1440. *(Object)*: The suite instance.
  1441. #### Example
  1442. ~~~ js
  1443. // basic usage
  1444. suite.run();
  1445. // or with options
  1446. suite.run({ 'async': true, 'queued': true });
  1447. ~~~
  1448. * * *
  1449. <!-- /div -->
  1450. <!-- div -->
  1451. ### <a id="benchmarksuiteprototypeshift"></a>`Benchmark.Suite.prototype.shift()`
  1452. <a href="#benchmarksuiteprototypeshift">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L671 "View in source") [&#x24C9;][1]
  1453. Removes the first element of the host array and returns it.
  1454. #### Returns
  1455. *(Mixed)*: The first element of the array.
  1456. * * *
  1457. <!-- /div -->
  1458. <!-- div -->
  1459. ### <a id="benchmarksuiteprototypeslicestart-end"></a>`Benchmark.Suite.prototype.slice(start, end)`
  1460. <a href="#benchmarksuiteprototypeslicestart-end">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L684 "View in source") [&#x24C9;][1]
  1461. Creates an array of the host array's elements from the start index up to, but not including, the end index.
  1462. #### Arguments
  1463. 1. `start` *(Number)*: The starting index.
  1464. 2. `end` *(Number)*: The end index.
  1465. #### Returns
  1466. *(Array)*: The new array.
  1467. * * *
  1468. <!-- /div -->
  1469. <!-- div -->
  1470. ### <a id="benchmarksuiteprototypesortcomparefnnull"></a>`Benchmark.Suite.prototype.sort([compareFn=null])`
  1471. <a href="#benchmarksuiteprototypesortcomparefnnull">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3823 "View in source") [&#x24C9;][1]
  1472. Sorts the benchmarks of the suite.
  1473. #### Arguments
  1474. 1. `[compareFn=null]` *(Function)*: A function that defines the sort order.
  1475. #### Returns
  1476. *(Object)*: The sorted suite.
  1477. * * *
  1478. <!-- /div -->
  1479. <!-- div -->
  1480. ### <a id="benchmarksuiteprototypesplicestart-deletecount--val1-val2-"></a>`Benchmark.Suite.prototype.splice(start, deleteCount [, val1, val2, ...])`
  1481. <a href="#benchmarksuiteprototypesplicestart-deletecount--val1-val2-">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L714 "View in source") [&#x24C9;][1]
  1482. Allows removing a range of elements and/or inserting elements into the host array.
  1483. #### Arguments
  1484. 1. `start` *(Number)*: The start index.
  1485. 2. `deleteCount` *(Number)*: The number of elements to delete.
  1486. 3. `[val1, val2, ...]` *(Mixed)*: values to insert at the `start` index.
  1487. #### Returns
  1488. *(Array)*: An array of removed elements.
  1489. * * *
  1490. <!-- /div -->
  1491. <!-- div -->
  1492. ### <a id="benchmarksuiteprototypeunshift"></a>`Benchmark.Suite.prototype.unshift()`
  1493. <a href="#benchmarksuiteprototypeunshift">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L749 "View in source") [&#x24C9;][1]
  1494. Appends arguments to the host array.
  1495. #### Returns
  1496. *(Number)*: The new length.
  1497. * * *
  1498. <!-- /div -->
  1499. <!-- /div -->
  1500. <!-- div -->
  1501. ## `Benchmark.Suite.options`
  1502. <!-- div -->
  1503. ### <a id="benchmarksuiteoptions"></a>`Benchmark.Suite.options`
  1504. <a href="#benchmarksuiteoptions">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3705 "View in source") [&#x24C9;][1]
  1505. *(Object)*: The default options copied by suite instances.
  1506. * * *
  1507. <!-- /div -->
  1508. <!-- div -->
  1509. ### <a id="benchmarksuiteoptionsname"></a>`Benchmark.Suite.options.name`
  1510. <a href="#benchmarksuiteoptionsname">#</a> [&#x24C8;](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3713 "View in source") [&#x24C9;][1]
  1511. *(String)*: The name of the suite.
  1512. * * *
  1513. <!-- /div -->
  1514. <!-- /div -->
  1515. <!-- /div -->
  1516. [1]: #Benchmark "Jump back to the TOC."