0.0.3 • Published 3 years ago
antutu-for-scripts v0.0.3
Antutu-for-scripts
Node.js progressive library to find out which script spends how many resources
Description
Shows the results in the form of a table for which script how many resources were spent
Installation
$ npm install antutu-for-scripts --save
Features
benchmark
benchmark(pathToFile:string, numOfIterations: (string | number), numOfRuns: (string | number))
Runs the test numOfRuns times with numOfIterations times iterations
[
{
title: 'Loop for',
Cpu: 80.5,
Memory: 1.8302,
Time: 0.08496,
infelicity: 0.03824,
diffTime: '0.0000'
},
{
title: 'Loop forEach',
Cpu: 84.5,
Memory: 1.84399,
Time: 0.09969,
infelicity: 0.02917,
diffTime: '17.3376'
},
{
title: 'Loop while',
Cpu: 91.5,
Memory: 1.81529,
Time: 0.17535,
infelicity: 0.10882,
diffTime: '106.3912'
}
]
print(resultOfBenchmark)
Prints the results as a table
Name of test | CPU (%) | RAM (mb) | Time (ms) | Infelicity time (ms) | Difference from best time (%) |
---|---|---|---|---|---|
Loop forEach | 83.75 | 1.8375 | 0.06969 | 0.10882 | 106.3912 |
Structure of test file
module.exports = {
title: 'Test file name',
tests: [
{
title: 'Test name',
method() {
// Сall or write a script that we want to test
}
},
]
};
Usage
For projects in javascript:
import {benchmark, print} from 'antutu-for-scripts';
try {
(async () => {
const benchmarkResult = await benchmark(pathToFile, numOfIterations, numOfRuns);
print(benchmarkResult);
})()
} catch(e) {
console.log(e.message);
process.exit(1);
}
For projects in typescript:
import {benchmark, print, IBenchmarkResult} from 'antutu-for-scripts';
try {
(async () => {
const benchmarkResult: IBenchmarkResult = await benchmark(pathToFile, numOfIterations, numOfRuns);
print(benchmarkResult);
})()
} catch(e) {
console.log(e.message);
process.exit(1);
}