Probabilistic Code Coverage

Inputs to programs generally follow a known distribution. For instance, a health program can expect height to be distributed around the mean height. This tool lets us test the program on its most common inputs and determine which lines of code are run the most.

Input the name of the function to analyze. The program will be analyzed with respect to variation in the parameters of this function.


To set the distribution of each parameter, add an entry of the format paramName=paramDistribution. For functions with multiple parameters, separate each entry onto a new line. The paramNames can be arbitrary but should be distinct among the parameters.

Possible values of paramDistribution are c, flip(p), geometric(p), binomial(n, p) for constant c, probability 0 < p < 1, and positive integer n.


This tool is meant for functional Javascript programs. As a result, general assignment expressions (var x = 2; ...; x = 5;) and looping constructs (for, while, do) are not supported. Functions should be written as var f = function(x, y) { ... }. Recursion is not supported at this time.

Paste the program into the text editor below. Click the line numbers to select which lines to analyze coverage for. Then, click "run" to do the analysis.


The result printed is an array of { "line": ..., "prob": ... } elements for each of the lines selected.

The probability "prob" assigned to each line represents the fraction of program executions distributed over all possible parameters that reached "line". For example, the first line of the function analyzed would always have a probability of 1, since it's always executed regardless of (syntactically valid) input.

Source code: https://github.com/shannoding/ppl-coverage