All Projects → JamieMason → Karma Benchmark

JamieMason / Karma Benchmark

Licence: mit
A Karma plugin to run Benchmark.js over multiple browsers with CI compatible output.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Karma Benchmark

Phoronix Test Suite
The Phoronix Test Suite open-source, cross-platform automated testing/benchmarking software.
Stars: ✭ 1,339 (+1421.59%)
Mutual labels:  performance, benchmark, benchmarking, profiling
Ezfio
Simple NVME/SAS/SATA SSD test framework for Linux and Windows
Stars: ✭ 91 (+3.41%)
Mutual labels:  performance, benchmark, benchmarking
Sysbench Docker Hpe
Sysbench Dockerfiles and Scripts for VM and Container benchmarking MySQL
Stars: ✭ 14 (-84.09%)
Mutual labels:  performance, benchmark, benchmarking
Jsbench Me
jsbench.me - JavaScript performance benchmarking playground
Stars: ✭ 50 (-43.18%)
Mutual labels:  benchmark, benchmarking, profiling
Bench Scripts
A compilation of Linux server benchmarking scripts.
Stars: ✭ 873 (+892.05%)
Mutual labels:  performance, benchmark, benchmarking
Profilinggo
A quick tour (or reminder) of Go performance tools
Stars: ✭ 219 (+148.86%)
Mutual labels:  performance, benchmarking, profiling
Pytest Benchmark
py.test fixture for benchmarking code
Stars: ✭ 730 (+729.55%)
Mutual labels:  performance, benchmark, benchmarking
Benchmarkdotnet
Powerful .NET library for benchmarking
Stars: ✭ 7,138 (+8011.36%)
Mutual labels:  performance, benchmark, benchmarking
Are We Fast Yet
Are We Fast Yet? Comparing Language Implementations with Objects, Closures, and Arrays
Stars: ✭ 161 (+82.95%)
Mutual labels:  performance, benchmark, benchmarking
Sltbench
C++ benchmark tool. Practical, stable and fast performance testing framework.
Stars: ✭ 137 (+55.68%)
Mutual labels:  performance, benchmark, benchmarking
Gatling Dubbo
A gatling plugin for running load tests on Apache Dubbo(https://github.com/apache/incubator-dubbo) and other java ecosystem.
Stars: ✭ 131 (+48.86%)
Mutual labels:  performance, benchmark, benchmarking
Processhacker
A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware.
Stars: ✭ 6,285 (+7042.05%)
Mutual labels:  performance, benchmarking, profiling
Web Tooling Benchmark
JavaScript benchmark for common web developer workloads
Stars: ✭ 290 (+229.55%)
Mutual labels:  performance, benchmark, benchmarking
Jsperf.com
jsperf.com v2. https://github.com/h5bp/lazyweb-requests/issues/174
Stars: ✭ 1,178 (+1238.64%)
Mutual labels:  performance, benchmark, benchmarking
Sequelize Benchmark
Benchmarks for sequelize
Stars: ✭ 8 (-90.91%)
Mutual labels:  performance, benchmark
Boomer
A better load generator for locust, written in golang.
Stars: ✭ 734 (+734.09%)
Mutual labels:  performance, benchmark
Likwid
Performance monitoring and benchmarking suite
Stars: ✭ 957 (+987.5%)
Mutual labels:  benchmarking, profiling
Rtb
Benchmarking tool to stress real-time protocols
Stars: ✭ 35 (-60.23%)
Mutual labels:  benchmark, benchmarking
Etrace
Emacs Lisp Latency Tracing for the Chromium Catapult Trace Event Format
Stars: ✭ 45 (-48.86%)
Mutual labels:  performance, profiling
Pibench
Benchmarking framework for index structures on persistent memory
Stars: ✭ 46 (-47.73%)
Mutual labels:  benchmark, benchmarking

karma-benchmark

A Karma plugin to run Benchmark.js over multiple browsers with CI compatible output.

NPM version NPM downloads Build Status Maintainability

Table of Contents

🌩 Installation

npm install --save-dev benchmark karma-benchmark

🕵🏾‍♀️ Reporters

⚖️ Configuration

In karma.conf.js, add 'benchmark' to the list of frameworks:

module.exports = config => {
  config.set({
    autoWatch: false,
    browsers: ["Chrome"],
    concurrency: 1,
    files: ["bench/**/*.bench.js"],
    frameworks: ["benchmark"],
    singleRun: true
  });
};

Terminal Reporting

Now let's add karma-benchmarkjs-reporter by @FormidableLabs to report results to the Terminal:

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

In karma.conf.js, add 'benchmark' to the list of reporters:

module.exports = (config) => {
  config.set({
    autoWatch: false,
    browsers: ['Chrome'],
    concurrency: 1,
    files: ['bench/**/*.bench.js'],
    frameworks: ['benchmark'],
+   reporters: ['benchmark'],
    singleRun: true
  });
};

JUnit Reporting

To feed our data into Continuous Integration, we can use the karma-junit-reporter.

npm install --save-dev karma-junit-reporter

In karma.conf.js, add junit to the list of reporters and configure the reporter accordingly:

module.exports = (config) => {
  config.set({
    autoWatch: false,
    browsers: ['Chrome'],
    concurrency: 1,
    files: ['bench/**/*.bench.js'],
    frameworks: ['benchmark'],
+   junitReporter: {
+     outputDir: 'reports',
+     outputFile: 'benchmark.xml'
+   },
-   reporters: ['benchmark'],
+   reporters: ['benchmark', 'junit'],
    singleRun: true
  });
};

Data Visualisation Reporting

With a free plot.ly account, we can generate visualisations using the karma-benchmark-plotly-reporter by @etpinard.

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

In karma.conf.js, add benchmark-plotly to the list of reporters and configure the reporter accordingly:

module.exports = (config) => {
  config.set({
    autoWatch: false,
+   benchmarkPlotlyReporter: {
+     username: '<your username>',
+     apiKey: '<your api key>',
+     cloudFilename: 'plotly-example',
+     imageFilename: 'plotly-example.png'
+   },
    browsers: ['Chrome'],
    concurrency: 1,
    files: ['bench/**/*.bench.js'],
    frameworks: ['benchmark'],
    junitReporter: {
      outputDir: 'reports',
      outputFile: 'benchmark.xml'
    },
-   reporters: ['benchmark', 'junit'],
+   reporters: ['benchmark', 'benchmark-plotly', 'junit'],
    singleRun: true
  });
};

👩🏻‍🔬 Writing Benchmarks

Benchmarks can be written by using the original Benchmark.js API, but a wrapper API is also provided by karma-benchmark in the form of the suite and benchmark globals. The karma-benchmark API aims to make the process of writing Benchmarks feel familiar to users of Jasmine or Jest.

In this example, a suite is defined that pits _.each against the native Array.forEach method:

suite("Array iteration", () => {
  benchmark("_.each", () => {
    _.each([1, 2, 3], el => {
      return el;
    });
  });

  benchmark("native forEach", () => {
    [1, 2, 3].forEach(el => {
      return el;
    });
  });
});

Suite options

Suite options are the same as in Benchmark.js with one exception: onStart and onComplete can be set at the suite level.

See the Benchmark.js Suite constructor API docs for a full list of options.

suite(
  "Array iteration",
  () => {
    benchmark("_.each", () => {
      _.each(this.list, number => {
        return number;
      });
    });

    benchmark("native forEach", () => {
      this.list.forEach(number => {
        return number;
      });
    });
  },
  {
    onCycle(event) {
      var suite = this;
      var benchmark = event.target;
      console.log("Cycle completed for " + suite.name + ": " + benchmark.name);
    },
    onStart() {
      this.list = [5, 4, 3];
    },
    onComplete() {
      this.list = null;
    }
  }
);

Benchmark options

Benchmark options are the same as in Benchmark.js. If setup and teardown are passed to benchmark(), they will override setup and teardown from the suite. Pass null or undefined to remove them.

See the Benchmark.js Benchmark constructor API docs for a full list of options.

suite("Iteration", () => {
  benchmark(
    "_.each with array",
    () => {
      _.each(this.list, number => {
        return number;
      });
    },
    {
      setup() {
        this.list = ["a", "b", "c"];
      },
      teardown() {
        delete this.list;
      }
    }
  );

  benchmark(
    "_.each with object",
    () => {
      _.each(this.list, number => {
        return number;
      });
    },
    {
      setup() {
        this.list = { 0: "a", 1: "b", 2: "c" };
      },
      teardown() {
        delete this.list;
      }
    }
  );
});

Running only a specific benchmark or suite

To run only a specific benchmark, use benchmark.only() or bbenchmark() instead of benchmark():

benchmark.only(() => {
  // Only this benchmark will run
  // bbenchmark() does the same thing
});

benchmark(() => {
  // This benchmark won't run
});

The same applies to suites with suite.only() and ssuite().

Skipping benchmarks & suites

To skip a benchmark, use benchmark.skip() or xbenchmark() instead of benchmark():

benchmark.skip(() => {
  // This benchmark won't run
  // xbenchmark() does the same thing
});

benchmark(() => {
  // This and all other benchmarks will run
});

The same applies to suites with suite.skip() and xsuite().

🙋🏾‍♂️ Getting Help

Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.

👀 Other Projects

If you find my Open Source projects useful, please share them ❤️

🤓 Author

I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.

Follow JamieMason on GitHub      Follow fold_left on Twitter

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].