Tag Archives: performance

Quiz: which ruby program uses more CPU?

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, [...]

Tagged | 1 Comment

Ruby Daemons: Verifying Good Behavior

If your ruby daemon isn’t doing something useful, it should be sleeping. A misbehaving daemon wakes up repeatedly, uses your CPU unnecessarily, and then goes back to sleep without doing anything helpful. It is easy to write a misbehaving daemon in Ruby, since you’re pretty well-insulated from what is actually happening at the operating system [...]

Also tagged | 1 Comment

Rails / Merb performance comparison (on mongrel, jruby, tomcat, glassfish)

[*****UPDATE 9/21/08: I've added Rails 2.1.1 and Rails 2.2 head stats for C MRI Ruby on Mongrel. Rails 2.2 tests pretty slow and the results should not be taken seriously until the Rails team comes to a point release and optimizes. I've also added tests with the MySQL C gem and Merb seems to get [...]

Also tagged , , | Comments closed