Skip to content

paulmelnikow/function-profiler

Repository files navigation

function-profiler

version license build code style

Profile a function. Print the elapsed time to the console.

Uses performance.now() and currently works only in the browser, though I'm open to making this isomorphic.

Motivation

I created this because I wanted to do something simple. The other packages I found were either much more complicated, or only worked in Node.

Usage

const profile = require('function-profiler')

const parsed = profile(yaml.safeLoad, 'Parsing yaml')(yamlStr)
const profile = require('function-profiler')

class Parser {
  parse(yamlStr) {
    return yaml.safeLoad(yamlStr)
  }
}

Parser.prototype.parse = profile(Parser.prototype.parse, 'Parsing YAML')

Installation

npm install --save function-profiler

Contribute

Pull requests welcome!

Support

If you are having issues, please let me know.

License

The project is licensed under the MIT license.