#!/usr/bin/env python
"""Benchmark erf."""

import timeit

name = "erf"
repeats = 3
iterations = 1000000


def print_version():
    """Print the TAP version."""

    print("TAP version 13")


def print_summary(total, passing):
    """Print the benchmark summary.

    # Arguments

    * `total`: total number of tests
    * `passing`: number of passing tests

    """

    print("#")
    print("1.." + str(total))  # TAP plan
    print("# total " + str(total))
    print("# pass  " + str(passing))
    print("#")
    print("# ok")


def print_results(elapsed):
    """Print benchmark results.

    # Arguments

    * `elapsed`: elapsed time (in seconds)

    # Examples

    ``` python
    python> print_results(0.131009101868)
    ```
    """

    rate = iterations / elapsed

    print("  ---")
    print("  iterations: " + str(iterations))
    print("  elapsed: " + str(elapsed))
    print("  rate: " + str(rate))
    print("  ...")


def benchmark():
    """Run the benchmark and print benchmark results."""

    setup = "from math import erf; from random import random;"
    stmt = "y = erf(1000.0*random() - 500.0)"

    t = timeit.Timer(stmt, setup=setup)

    print_version()

    for i in xrange(repeats):
        print("# python::" + name)
        elapsed = t.timeit(number=iterations)
        print_results(elapsed)
        print("ok " + str(i+1) + " benchmark finished")

    print_summary(repeats, repeats)


def main():
    """Run the benchmark."""
    benchmark()


if __name__ == "__main__":
    main()

@@ -37,16 +37,54 @@
 rf.%22%22%22%0A%0A
+from __future__ import print_function%0A
 import t
@@ -90,20 +90,20 @@
 timeit%0A%0A
-name
+NAME
  = %22erf%22
@@ -107,30 +107,30 @@
 rf%22%0A
-repeats = 3%0Aiterations
+REPEATS = 3%0AITERATIONS
  = 1
@@ -188,25 +188,24 @@
 version.%22%22%22%0A
-%0A
     print(%22T
@@ -394,25 +394,24 @@
 ts%0A%0A    %22%22%22%0A
-%0A
     print(%22#
@@ -769,25 +769,24 @@
 %60%60%60%0A    %22%22%22%0A
-%0A
     rate = i
@@ -784,26 +784,26 @@
  rate = 
-iterations
+ITERATIONS
  / elaps
@@ -858,26 +858,26 @@
 %22 + str(
-iterations
+ITERATIONS
 ))%0A    p
@@ -1040,17 +1040,16 @@
 lts.%22%22%22%0A
-%0A
     setu
@@ -1232,23 +1232,23 @@
  xrange(
-repeats
+REPEATS
 ):%0A     
@@ -1271,20 +1271,20 @@
 on::%22 + 
-name
+NAME
 )%0A      
@@ -1311,26 +1311,26 @@
 (number=
-iterations
+ITERATIONS
 )%0A      
@@ -1433,24 +1433,24 @@
 ary(
-repeats, repeats
+REPEATS, REPEATS
 )%0A%0A%0A

Fix lint errors