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
- Host: GitHub
- URL: https://github.com/mefistosss/performance-js-tests
- Owner: Mefistosss
- Created: 2019-11-05T14:00:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-05T17:28:10.000Z (over 6 years ago)
- Last Synced: 2025-03-18T11:20:04.573Z (over 1 year ago)
- Topics: performance, testing
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)