Source

unitbench / src / doc / getting_started.rst

Getting Started

I tried to design the library to be vary easy to use. Here is some simple example code to get you started.

Simple Prime Generation Benchmarks

Example Console Output

The default output includes the name of each benchmark. It is derived from the name of the function used to generate it. The user, system, and real times reported are the averages of the default number of runs (7).

Example CSV Output

First, changing the output to CSV requires this change::

if __name__ == "__main__":
    PrimeBenchmark().run(CsvReporter())

Then it produces this output::

Name,Value,Call Count,Wall Minimum,Wall Maximum,Wall Average,Wall Standard Deviation,Wall Variance
Naive Primes,100,7,5.79357147217e-05,6.19888305664e-05,5.91278076172e-05,1.26159253648e-06,1.5916157281e-12
Naive Primes,1000,7,0.000690937042236,0.000741958618164,0.000701870237078,1.66158757018e-05,2.76087325337e-10
Naive Primes,10000,7,0.00882005691528,0.00918817520142,0.00898504257202,0.000157213352588,2.47160382319e-08
Naive Primes,100000,7,0.139157056808,0.139923095703,0.139575345176,0.00023467537773,5.50725329125e-08
Sieve Of Eratosthenes,100,7,1.81198120117e-05,2.59876251221e-05,1.98568616595e-05,2.52226537726e-06,6.36182263332e-12
Sieve Of Eratosthenes,1000,7,0.000169038772583,0.000175952911377,0.000171593257359,2.83740801125e-06,8.05088422233e-12
Sieve Of Eratosthenes,10000,7,0.00182700157166,0.00192213058472,0.00187890870231,3.14177212374e-05,9.87073207751e-10
Sieve Of Eratosthenes,100000,7,0.0235598087311,0.0260169506073,0.0249668530055,0.000736537686839,5.42487764134e-07