Author: Remi Meier <[email protected]>
Branch: multithread-runner
Changeset: r365:a417ae48b64d
Date: 2016-06-02 15:46 +0200
http://bitbucket.org/pypy/benchmarks/changeset/a417ae48b64d/

Log:    fix a few benchmarks and better configuration

diff --git a/multithread/common/abstract_threading.py 
b/multithread/common/abstract_threading.py
--- a/multithread/common/abstract_threading.py
+++ b/multithread/common/abstract_threading.py
@@ -128,6 +128,9 @@
         for w in self.workers:
             w.join()
 
+    def __str__(self):
+        return "TP(%s)" % len(self.workers)
+
 
 _thread_pool = ThreadPool()
 atexit.register(_thread_pool.shutdown)
@@ -136,6 +139,7 @@
     global _thread_pool
     if _thread_pool:
         _thread_pool.shutdown()
+    print "set_thread_pool", th
     _thread_pool = th
 
 
diff --git a/multithread/config-all-short.json 
b/multithread/config-all-short.json
--- a/multithread/config-all-short.json
+++ b/multithread/config-all-short.json
@@ -24,7 +24,7 @@
         "mersenne": {
             "file": "mersenne/mersenne.py",
             "PYTHONPATH": "..",
-            "args": ["1500"]
+            "args": ["2000"]
         },
 
         "richards": {
@@ -48,7 +48,7 @@
         "skiplist": {
             "file": "skiplist/skiplist.py",
             "PYTHONPATH": "..",
-            "args": ["16", "100000"]
+            "args": ["16", "200000"]
         },
 
         "raytrace": {
diff --git a/multithread/mersenne/mersenne.py b/multithread/mersenne/mersenne.py
--- a/multithread/mersenne/mersenne.py
+++ b/multithread/mersenne/mersenne.py
@@ -73,7 +73,9 @@
 
     counter = [0]
     fs = []
-    for ps in chunks(xrange(2, upb_prime+1), 500):
+    cs = list(chunks(xrange(2, upb_prime+1), 100))
+    print len(cs), "futures"
+    for ps in cs:
         fs.append(Future(work, ps, counter, upb_count))
 
     [f() for f in fs]
diff --git a/multithread/nqueens/nqueens.py b/multithread/nqueens/nqueens.py
--- a/multithread/nqueens/nqueens.py
+++ b/multithread/nqueens/nqueens.py
@@ -6,7 +6,7 @@
 # of the execution time constructing the permutations. Thus
 # only half the execution is parallelised.
 
-
+import gc
 import sys
 import time
 from common.abstract_threading import (
@@ -40,13 +40,17 @@
     solutions = []
     fs = []
     cols = range(n)
-    for perms in chunks(permutations(cols), 10000):
+    cs = list(chunks(permutations(cols), 10000))
+    gc.collect()
+    t = time.time()
+    for perms in cs:
         fs.append(Future(check_solutions, n, cols, perms))
     print "Futures:", len(fs)
     for f in fs:
         solutions.extend(f())
-
+    t = time.time() - t
     print "found:", len(solutions)
+    return t
 
 
 def run(threads=2, n=10):
@@ -55,11 +59,11 @@
 
     set_thread_pool(ThreadPool(threads))
 
-    find_solutions(n)
+    t = find_solutions(n)
 
     # shutdown current pool
     set_thread_pool(None)
-
+    return t
 
 def main(argv):
     # warmiters threads args...
@@ -71,20 +75,18 @@
 
     print "do warmup:"
     for i in range(3):
-        t = time.time()
-        run(threads, n)
-        print "iter", i, "time:", time.time() - t
+        t = run(threads, n)
+        print "iter", i, "time:", t
 
     print "turn off jitting"
-    import gc
     turn_jitting_off()
     print "do", warmiters, "real iters:"
     times = []
     for i in range(warmiters):
         gc.collect()
-        t = time.time()
-        run(threads, n)
-        times.append(time.time() - t)
+
+        t = run(threads, n)
+        times.append(t)
     print "warmiters:", times
 
 if __name__ == "__main__":
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to