11#!/usr/bin/env python
22"""Benchmark atanh."""
33
4+ from __future__ import print_function
45import timeit
56
6- name = "atanh"
7- repeats = 3
8- iterations = 1000000
7+ NAME = "atanh"
8+ REPEATS = 3
9+ ITERATIONS = 1000000
910
1011
1112def print_version ():
1213 """Print the TAP version."""
13-
1414 print ("TAP version 13" )
1515
1616
@@ -23,7 +23,6 @@ def print_summary(total, passing):
2323 * `passing`: number of passing tests
2424
2525 """
26-
2726 print ("#" )
2827 print ("1.." + str (total )) # TAP plan
2928 print ("# total " + str (total ))
@@ -45,33 +44,31 @@ def print_results(elapsed):
4544 python> print_results(0.131009101868)
4645 ```
4746 """
48-
49- rate = iterations / elapsed
47+ rate = ITERATIONS / elapsed
5048
5149 print (" ---" )
52- print (" iterations: " + str (iterations ))
50+ print (" iterations: " + str (ITERATIONS ))
5351 print (" elapsed: " + str (elapsed ))
5452 print (" rate: " + str (rate ))
5553 print (" ..." )
5654
5755
5856def benchmark ():
5957 """Run the benchmark and print benchmark results."""
60-
6158 setup = "from math import atanh; from random import random;"
6259 stmt = "y = atanh(2.0*random() - 1.0)"
6360
6461 t = timeit .Timer (stmt , setup = setup )
6562
6663 print_version ()
6764
68- for i in xrange (repeats ):
69- print ("# python::" + name )
70- elapsed = t .timeit (number = iterations )
65+ for i in xrange (REPEATS ):
66+ print ("# python::" + NAME )
67+ elapsed = t .timeit (number = ITERATIONS )
7168 print_results (elapsed )
7269 print ("ok " + str (i + 1 ) + " benchmark finished" )
7370
74- print_summary (repeats , repeats )
71+ print_summary (REPEATS , REPEATS )
7572
7673
7774def main ():
0 commit comments