zTest

Statistical Benchmarking for JavaScript

View project onGitHub

zTest

zTest is a benchmarking suite for JavaScript, providing statistical testing of performance "experiments." In statistics, an alternative can be proven superior by the rejection of a null hypothesis - that there is no discrepancy in merit. Hence, zTest operates on the idea of rejecting beyond reasonable doubt the idea of performance being equivalent between two procedures.

Usage

The zTest library may be used with Node.js, as in example.js in the source, or on the client-side. To perform a test, pass a control function, an experiment function, and a sample size to the ztest function.

var result = ztest(function() {
  var i = 100;
  while(i--);
  return;
}, function() {
  var i = 99;
  while(i--);
  return;
}, 1000000)

Results are encoded as follows.

{
  "fns": [function(){...}, function(){...}],
  "winner": 0,
  "desc": "The null was rejected; the control is more efficient."
}