[pypy-commit] benchmarks default: Add a mini benchmark.
arigo
noreply at buildbot.pypy.org
Fri Jul 4 18:22:09 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r264:620a3e907582
Date: 2014-07-04 18:21 +0200
http://bitbucket.org/pypy/benchmarks/changeset/620a3e907582/
Log: Add a mini benchmark.
diff --git a/multithread/minibench1.py b/multithread/minibench1.py
new file mode 100644
--- /dev/null
+++ b/multithread/minibench1.py
@@ -0,0 +1,28 @@
+import thread, sys
+
+def f(n, lock):
+ total = 0
+ lst1 = ["foo"]
+ for i in xrange(n):
+ lst1.append(i)
+ total += lst1.pop()
+ sys.stdout.write('%d\n' % total)
+ lock.release()
+
+
+T = 4 # number of threads
+N = 100000000 # number of iterations in each thread
+if len(sys.argv) >= 2:
+ T = int(sys.argv[1])
+ if len(sys.argv) >= 3:
+ N = int(sys.argv[2])
+
+locks = []
+for i in range(T):
+ lock = thread.allocate_lock()
+ lock.acquire()
+ locks.append(lock)
+ thread.start_new_thread(f, (N, lock))
+
+for lock in locks:
+ lock.acquire()
More information about the pypy-commit
mailing list