Package Exports
- benchscript
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (benchscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Benchmark for functions written on typescript
A console application based on NodeJs.
This is a minimal console application for benchmarking your functions on NodeJS application written in TypeScript or JS. Application calculates time to run a function, cpu usage, and ram usage.
Use this app along with NodeJS and TypeScript. NodeJs TypeScript
A basic Benchmark application needs just few files to run and test your code:
package.json- Points to the app's main file and lists its details and dependencies.tsconfig.json- Has all configurations needed for TypeScript file to compile properly.
To Use
To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:
# Clone this repository
git clone https://codykhon@bitbucket.org/abdullayev-qodirjon/newbench.git
# Go into the repository
cd BENCHMARK
# Install dependencies
npm install
# Compile all TypeScript files
tsc
# Test your run
npm run bench ./dist/SampleBench/functions.js 1000 100
Note: If you're using Linux Bash for Windows, see this guide or use node from the command prompt.
How to use.
For using benchmark on your function you need to go through few steps:
- Create a TypeScript file containing your test functions as below:
export const testFunctions = [
{
title: "SampleTitle1",
fn: function YourFunction1() {
//Does something
},
},
{
title: "SampleTitle2",
fn: function YourFunction2() {
//Does something
},
},
{
title: "SampleTitle3",
fn: function YourFunction3() {
//Does something
},
},
];- Or create a JavaScript file containing your test functions as below:
Object.defineProperty(exports, "__esModule", { value: true });
exports.testFunctions = [
{
title: "SampleTitle1",
fn: function YourFunction1() {
//Does something
},
},
{
title: "SampleTitle2",
fn: function YourFunction3() {
//Does something
},
},
{
title: "SampleTitle3",
fn: function YourFunction3() {
//Does something
},
},
];Save your file and copy it`s path
Run bash command and put you file path into it
Give number of iterations(number of how many times each function needed to be called on each run)
Give number of runs(number of runs for calculating average results after dumping)
npm run bench /YourTestFilePath "-number of iterations" "-number of runs"- Get results:
┌───────────────┬───────────────────┬──────────┬───────────┬───────────────────────────────┬─────────────────┐
│ Title │ Average Time (ms) │ CPU (%) │ RAM (MB) │ Average Infelicity Time (ms) │ Difference (%) │
├───────────────┼───────────────────┼──────────┼───────────┼───────────────────────────────┼─────────────────┤
│ SampleTitle1 │ xxxxx │ xxxxx │ xxxxx │ xxxxx │ Best │
│ SampleTitle2 │ xxxxx │ xxxxx │ xxxxx │ xxxxx │ Slower by xxxxx │
│ SampleTitle3 │ xxxxx │ xxxxx │ xxxxx │ xxxxx │ Slower by xxxxx │
└───────────────┴───────────────────┴──────────┴───────────┴───────────────────────────────┴─────────────────┘