Author: Armin Rigo <ar...@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() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit