Spaces:
Sleeping
Sleeping
File size: 1,284 Bytes
ebb869a 77a34f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
---
sdk: docker
---
# eruda-benchmark
[![NPM version][npm-image]][npm-url]
[![License][license-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/eruda-benchmark.svg
[npm-url]: https://npmjs.org/package/eruda-benchmark
[license-image]: https://img.shields.io/npm/l/eruda-benchmark.svg
Eruda plugin for running JavaScript benchmarks.
## Demo
Browse it on your phone:
[http://eruda.liriliri.io/?plugin=benchmark](http://eruda.liriliri.io/?plugin=benchmark)
## Install
```bash
npm install eruda-benchmark --save
```
```javascript
eruda.add(erudaBenchmark);
```
Make sure Eruda is loaded before this plugin, otherwise won't work.
## Usage
After initialization:
```javascript
var benchmark = eruda.get('benchmark');
benchmark.add('Test', function ()
{
var arr = new Array(10000);
for (var i = 0; i < 10000; i++) arr[i] = i * 2;
});
benchmark.add('Test Suite', [
{
name: 'RegExp#test',
fn: function ()
{
/o/.test('Hello World!');
}
},
{
name: 'String#indexOf',
fn: function ()
{
'Hello World!'.indexOf('o') > -1;
}
},
{
name: 'String#match',
fn: function ()
{
!!'Hello World!'.match(/o/);
}
}
]);
``` |