[pypy-commit] benchmarks default: (__stian__) add pidigits benchmark to the nightly run
fijal
noreply at buildbot.pypy.org
Fri Aug 31 09:16:56 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r189:f054077717fa
Date: 2012-08-30 22:07 +0200
http://bitbucket.org/pypy/benchmarks/changeset/f054077717fa/
Log: (__stian__) add pidigits benchmark to the nightly run
diff --git a/benchmarks.py b/benchmarks.py
--- a/benchmarks.py
+++ b/benchmarks.py
@@ -41,6 +41,7 @@
opts = {
'gcbench' : {'iteration_scaling' : .10},
+ 'pidigits': {'iteration_scaling' : .10},
'bm_mako' : {'bm_env': {'PYTHONPATH': relative('lib/mako')}},
'bm_chameleon': {'bm_env': {'PYTHONPATH': relative('lib/chameleon/src')},
'iteration_scaling': 3},
@@ -60,7 +61,7 @@
for name in ['float', 'nbody_modified', 'meteor-contest', 'fannkuch',
'spectral-norm', 'chaos', 'telco', 'go', 'pyflate-fast',
'raytrace-simple', 'crypto_pyaes', 'bm_mako', 'bm_chameleon',
- 'json_bench']:
+ 'json_bench', 'pidigits']:
_register_new_bm(name, name, globals(), **opts.get(name, {}))
for name in ['names', 'iteration', 'tcp', 'pb', ]:#'web']:#, 'accepts']:
if name == 'web':
diff --git a/own/pidigits.py b/own/pidigits.py
new file mode 100644
--- /dev/null
+++ b/own/pidigits.py
@@ -0,0 +1,47 @@
+import time
+
+PIDIGITS_LEN = 15000
+
+def pidigits(length):
+ i = k = ns = 0
+ k1 = 1
+ n,a,d,t,u = 1,0,1,0,0
+ while(True):
+ k += 1
+ t = n<<1
+ n *= k
+ a += t
+ k1 += 2
+ a *= k1
+ d *= k1
+ if a >= n:
+ t,u = divmod(n*3 + a,d)
+ u += n
+ if d > u:
+ ns = ns*10 + t
+ i += 1
+ if i % 10 == 0:
+ ns = 0
+ if i >= length:
+ break
+ a -= d*t
+ a *= 10
+ n *= 10
+
+def main(n):
+ l = []
+ for i in range(n):
+ t0 = time.time()
+ pidigits(PIDIGITS_LEN)
+ l.append(time.time() - t0)
+ return l
+
+if __name__ == '__main__':
+ import util, optparse
+ parser = optparse.OptionParser(
+ usage="%prog [options]",
+ description="Test the pidigit calculation performance")
+ util.add_standard_options_to(parser)
+ options, args = parser.parse_args()
+
+ util.run_benchmark(options, options.num_runs, main)
More information about the pypy-commit
mailing list