Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r281:69152c2aee77
Date: 2014-11-05 16:45 +0200
http://bitbucket.org/pypy/benchmarks/changeset/69152c2aee77/

Log:    fine, add the fibonacci here

diff --git a/own/fib.py b/own/fib.py
new file mode 100644
--- /dev/null
+++ b/own/fib.py
@@ -0,0 +1,31 @@
+
+import sys, time
+
+def fib(n):
+    if n == 0 or n == 1:
+        return 1
+    return fib(n - 1) + fib(n - 2)
+
+def f(n):
+    times = []
+    for k in range(n):
+        t0 = time.time()
+        for i in range(2000):
+            fib(20)
+        times.append(time.time() - t0)
+    return times
+
+def entry_point(argv):
+    import optparse
+    import util
+
+    parser = optparse.OptionParser(
+        usage="%prog [options]",
+        description="Test the performance of the fibonacci benchmark")
+    util.add_standard_options_to(parser)
+    options, args = parser.parse_args(argv)
+    util.run_benchmark(options, options.num_runs, f)
+
+if __name__ == '__main__':
+    entry_point(sys.argv[1:])
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to