An open API service indexing awesome lists of open source software.

https://github.com/mefistosss/performance-js-tests

Shows the average value of running js
https://github.com/mefistosss/performance-js-tests

performance testing

Last synced: over 1 year ago
JSON representation

Shows the average value of running js

Awesome Lists containing this project

README

          

# performance-js-tests

## Install

```
$ npm install --save performance-js-tests
```

## Usage

### testable.js
```js
// for example
window.somethingHappened = (callback) => {
setTimeout(callback, 1000);
};
```

### index.html
```html


const startTime = +new Date();


somethingHappened(() => {
const currentTime = +new Date();
window.onCustomEvent({ type: 'timeStamp', data: currentTime - startTime });
});

```

### performance test
```js
const performanceTests = require('performance-js-tests');

(async() => {
await performanceTests({
puppeteer: {
htmlFile: 'index.html'
}
});
})()
```
Browser will launch 100 times and you can see average file download or performance of js in ms

## Options

```js
{
// number of launched browsers
numberOfStarts: 100,

// maximum latency from the browser
waitingTime: 30000,

// koa
server: {
enable: true,
port: 3000,
baseDir: '.',

staticKoaOptions: {
// see link below
},

rewrite: {
// see link below
}
},

puppeteer: {
// will launch firefox-launch instead of chrome-launch
useFirefox: false,

// html file where js is launched
htmlFile: null,
launchOptions: {
// see link below
}
}
}
````

[staticKoaOptions](https://github.com/koajs/static)
[rewrite](https://github.com/koajs/rewrite)
[launchOptions](https://github.com/GoogleChrome/puppeteer#default-runtime-settings)