MCPcopy Index your code
hub / github.com/python/cpython / test_calc_pi

Function test_calc_pi

Modules/_decimal/tests/bench.py:83–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 return _increase_int_max_str_digits
82
83def test_calc_pi():
84 print("\n# ======================================================================")
85 print("# Calculating pi, 10000 iterations")
86 print("# ======================================================================\n")
87
88 to_benchmark = [pi_float, pi_decimal]
89 if C is not None:
90 to_benchmark.insert(1, pi_cdecimal)
91
92 for prec in [9, 19]:
93 print("\nPrecision: %d decimal digits\n" % prec)
94 for func in to_benchmark:
95 start = time.time()
96 if C is not None:
97 C.getcontext().prec = prec
98 P.getcontext().prec = prec
99 for i in range(10000):
100 x = func()
101 print("%s:" % func.__name__.replace("pi_", ""))
102 print("result: %s" % str(x))
103 print("time: %fs\n" % (time.time()-start))
104
105@increase_int_max_str_digits(maxdigits=10000000)
106def test_factorial():

Callers 1

bench.pyFile · 0.85

Calls 5

strFunction · 0.85
funcFunction · 0.50
insertMethod · 0.45
timeMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…