# perfor

> Javascript/Typescript performance tests

Latest version **1.0.1** (published 2020-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install perfor
pnpm add perfor
yarn add perfor
bun add perfor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-05-25 |
| First published | 2020-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel Mazurkiewicz |
| Maintainers | danielmazurkiewicz |
| Keywords | test, tests, performance |

## Links

- npm: https://www.npmjs.com/package/perfor
- Repository: https://github.com/DanielMazurkiewicz/perfor
- Homepage: https://github.com/DanielMazurkiewicz/perfor#readme
- Issues: https://github.com/DanielMazurkiewicz/perfor/issues
- npm.io page: https://npm.io/package/perfor

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^14.0.5

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-05-25
- 1.0.0 — 2020-05-24

## README

# perfor
Javascript/Typescript performance tests


# Installation
```sh
yarn add perfor --dev
```

# Usage

File "testGroup1.ts" (or "testGroup1.js")
```javascript
import { testGroup } from 'perfor';

testGroup('Performance test group #1', (test) => {
    test('Performance test #1', () => {
        // your code to test its performance here
    });

    test('Performance test #2', () => {
        // your code to test its performance here
    });
});
```

File "testsRun.ts" (or "testsRun.js")
```javascript
import { testStart } from 'perfor';;
import './testsGroup1';

testStart({ 
    // if provided then test result will be stored to given file
    storeToFile: './testResults.json',

    // if provided then test results will be printed to console
    console: true,

    // if provided then printed to console results will contain comparison with last stored test result in given file
    comparisonFile: './testResults.json'
})
```

# How it works

Each test is executed in loop for at least half a second, if you find results not precise enough you can change a minimum execution time like this:
```javascript
import { testGroup } from 'perfor';

testGroup('Performance test group #2', (test) => {
    test('Performance test #1', () => {
        // your code to test its performance here
    }, 1000); // <- test will run for at least one second (1000ms)
});
```

# Testing tips

For test results to be comparable between each tests run:
* Turn off all kind of dynamic frequency management and all sorts of "frequency boosts" of your processor
* Set fixed low frequency of your processor to avoid any sort of throttling
* Always run tests on exactly same machine configuration

Alternatively - run tests in software VM with fake real time clock where time is corelated with number of executed instructions for example (and not at all with a real time)

---
_Source: https://npm.io/package/perfor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
