@superhuit/starterpack-perfs-tester
v0.0.5-2
Published
An utility package to test performances of your application's parts
Downloads
7
Keywords
Readme
Perfs Tester
An utility package to test performances of your application's parts
Requirements
- node = lts/hydrogen (v18.x)
Getting started
Setup
Add perf_hooks: false,
to next.config.js file in webpack resolve fallback property
// [...]
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.resolve.plugins.push(new TsconfigPathsPlugin());
config.resolve = {
...config.resolve,
fallback: {
...config.resolve.fallback,
perf_hooks: false, // <== Add here
},
};
// [...]
Usage
- Import the package
import Benchmark from '@superhuit/starterpack-perfs-tester';
Simple
Mark timing segments in your application
- Start a performance test
- Mark timings
- Report
const perfsTester = PerfsTester();
// application logic 1
perfsTester.mark('logic 1');
// application logic 2
perfsTester.mark('logic 2');
// application logic 3
perfsTester.mark('logic 3');
// application logic 4
perfsTester.mark('logic 4');
perfsTester.report('Application logics');
Specific
Test sepecific blocks performances
- Start a performance test
- Mark start of block
- End block test
- Report
function foo() {
const testFooId = perfsTester.markStart('function Foo');
// do something heavy
perfsTester.markEnd(testFooId);
}
const perfsTester = PerfsTester();
foo();
perfsTester.report();