Skip to content

an easy and simple way to benchmark your javascript code

Notifications You must be signed in to change notification settings

houssemba/babel-plugin-jsperf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-jsperf

an easy way to benchmark your javascript code

Build Status codecov Known Vulnerabilities

Installation

npm install --save-dev babel-plugin-jsperf

Usage

.babelrc

.babelrc

{
  "plugins": ["jsperf"]
}

CLI

babel --plugins jsperf code.js -o out.js

Examples

// jsperf
function todo() {
  console.log('toto');
}

↓ ↓ ↓ ↓ ↓ ↓

// jsperf
function todo() {
  console.time('todo');
  console.log('toto');
  console.timeEnd('todo');
}

const foo = /* jsperf */ () => 'test';

↓ ↓ ↓ ↓ ↓ ↓

const foo = /* jsperf */function () {
  console.time('foo');
  var _returnValue = 'test';
  console.timeEnd('foo');
  return _returnValue;
};

class clazz {
  // jsperf
  method() {
    console.log('class method !');
  }
}

↓ ↓ ↓ ↓ ↓ ↓

class clazz {
  // jsperf
  method() {
    console.time('function2');
    console.log('class method !');
    console.timeEnd('function2');
  }
}

// jsperf
function foo() {
  const bar = 'bar';
  return bar;
}

↓ ↓ ↓ ↓ ↓ ↓

// jsperf
function foo() {
  console.time('foo');
  const bar = 'bar';
  var _returnValue = bar;
  console.timeEnd('foo');
  return _returnValue;
}

About

an easy and simple way to benchmark your javascript code

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •