Program A:
sleep(100)
Program B:
t = Thread.new do
sleep(100)
end
t.join
Which program uses more CPU? Hint: this is ruby 1.8.6.
The simple test
Run both programs overnight (surround the sleep(100) with a repeating while), and ‘ps aux’ to see cpu usage.
The complex test that explains what is happening
Run both programs with valgrind / kcachegrind, or pop into gdb.
The answer
Now, [...]