Giter Club home page Giter Club logo

karma-benchmarkjs-reporter's Introduction

Karma Benchmark.js Reporter

A configurable Karma reporter for the karma-benchmark plugin.

Installation

npm install karma-benchmark karma-benchmarkjs-reporter --save-dev

Karma Configuration

Add benchmark to your frameworks and reporters arrays. Optionally, specify a benchmarkReporter config object:

module.exports = function(config) {
  config.set({
    // ...
    frameworks: ["benchmark"],
    reporters: ["benchmark"],
    // optional configuration object :
    benchmarkReporter: {
      colors: config.colors,
      style: style,
      decorator: "-",
      terminalWidth: 60,
      hzWidth: 4,
      hzUnits: "ops/sec",
      browserWidth: 40,
      showBrowser: false,
      showSuiteSummary: false,
      formatBenchmark: formatBenchmark,
      formatSuiteHeading: formatSuiteHeading,
      formatSuiteSummary: formatSuiteSummary
    }
  });
};

Options

colors

default: true

This value is inherited from Karma, but you can override it by specifying a boolean.

style

default:

{
  benchmark: chalk.stripColor,
  summaryBenchmark: chalk.underline,
  summaryEmphasis: chalk.bold.underline,
  browser: chalk.blue,
  decorator: chalk.cyan,
  hz: chalk.green,
  hzUnits: chalk.italic.dim,
  suite: chalk.bold.magenta
}

The style object contains the styling functions for each piece of data. The default uses chalk for styling and color.

decorator

default: "-"

The decorator for the beginning of each benchmark row.

terminalWidth

default: 60

The default formatting functions attempt to match this column width for each row. There is still possibility for overflow.

hzWidth

default: 4

The default formatting functions use this to pad the formatted hz string.

hzUnits

default: "ops/sec"

The string placed after the hz as units.

browserWidth

default: 40

The default formatting functions use this to pad the browser name.

showBrowser

default: false

The default formatting functions only output the browser name if set to true. It is useful if you are benchmarking multiple browsers.

showSuiteSummary

default: false

Specify if you want to call the formatSuiteSummary function at the end of a suite.

Formatting functions

If you override the default formatting functions, you must ensure that your functions take into account the other configuration values (if you want to use them).

View the default formatting functions

/**
 * @param  {Object} benchmark the benchmark to be formatted
 * @param  {Object} browser the browser associated with the benchmark
 * @param  {Object} benchConfig the benchmarkReporter config obj
 * @return {string} the formatted benchmark
 */
var formatBenchmark = function (benchmark, browser, benchConfig) {...};

/**
 * @param  {string} suiteName name of performance suite
 * @param  {Object} browser browser object
 * @param  {Object} benchConfig benchmarkReporter config object
 * @return {string} formatted suite heading
 */
var formatSuiteHeading = function (suiteName, browser, benchConfig) {...};

/**
 * @param  {Object[]} suite array of browserBenchmarks: `{browser: {Obj}, benchmark: {Obj}`
 * @param  {Object} benchConfig benchmarkReporter config obj
 * @return {string} the formatted suite summary
 */
var formatSuiteSummary = function (suite, benchConfig) {

karma-benchmarkjs-reporter's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.