3 ms·
Attempting the slide 3 example on a dual-core Core 2 Duo CPU running 32-bit Linux with Python 2.6 I get * single-threaded: 8.9s * two threads: 10.4s Overh
by mgedmin 17y ago
Attempting the slide 3 example on a dual-core Core 2 Duo CPU running 32-bit Linux with Python 2.6 I get
* single-threaded: 8.9s
* two threads: 10.4s
Overhead is ~17% (compare to 2X slowdown reported on quad-core Mac OS X). Interesting.
- crad 17y agoHe did mention in the talk that Linux does not act as weird due to the scheduler differences.
- kingkilr 17y agoI thought he said the reason Linux performance was better was because the locks were better?
- d0mine 17y agoFor 4-cores CPU running 64-bit Linux with Python 2.6: * single-threaded: 7.6s * two threads: 8.8s * 4 threads: 9.14s * 4 processes (via multiprocessing) 2.0s Overhead is ~16-20% (5% for multiprocessing) #!/usr/bin/env python from threading import Thread from multiprocessing import Process def countdown(n): while n > 0: n -= 1 COUNT = 100000000 def run_once(): countdown(COUNT) def run_with_threads(nthreads, make_thread=Process): threads = [make_thread(target=countdown, args=(COUNT//nthreads,)) for _ in range(nthreads)] for t in threads: t.start() for t in threads: t.join()