Thursday, July 17, 2008

Interesting... that is all

Just read this post...

Just saying... it's interesting.  Seems to be a lot of the benchmarking bug going around these days.

Thursday, July 3, 2008

JRuby slowdown from Rails 2.0.2 to 2.1.0

Before you decide to bring your current JRuby on Rails app to the latest 2.1.0 version... you may want to take a look at the performance. I was running the console benchmark from this blog post with jruby trunk and saw some numbers I wasn't expecting:
[sourcecode language="ruby"]
in console: 6.times {puts Benchmark.measure {10000.times {Person.find :first}}.total}
4.47 : jruby 1.1.2 & rails 2.0.2 (jdbc) (best out of 6 runs)
5.43 : jruby 1.1.2 & rails 2.1.0 (jdbc)
4.12 : jruby 1.1.3 (trunk) & rails 2.0.2 (jdbc)
5.06 : jruby 1.1.3 (trunk) & rails 2.1.0 (jdbc)
[/sourcecode]

JRuby trunk IS faster than 1.1.2 as expected, but JRuby overall is experiencing a (pretty significant) slowdown when running Rails 2.1.0.

Hopefully finding the culprit for this slowdown will open the floodgates for improving JRuby on Rails performance.

Friday, May 30, 2008

Loss of internet connection...

When you have to write something like this (on mac), things are bad mmmmkay?

[sourcecode language="ruby"]
loop do
if system('curl -m 2 http://google.com')
system("say \"Mike! Cox Communications has finally fixed the lines, we're back in business!\"")
end
sleep(30)
end
[/sourcecode]

Tuesday, May 27, 2008

Syntactic Sugar...

Was reading this post about Groovy syntactic sugar... closures and ++ operator are nice... but you could open up Hash and Array to get the other stuff.

[sourcecode language="ruby"]
# working with hashes
class Hash
def method_missing(name, *args)
fetch(name) if has_key?(name) or nil
end
end
user = {:save => true, :destroy => false}
puts "--hashes"
puts "save? : #{user.save}"
puts "destroy? : #{user.destroy}"

# working with arrays
class Array
def method_missing(name, *args)
collect {|i| i.send(name)}
end
end
puts "--upcase"
puts ["Mike", "McKinney"].upcase

# fetching attributes of arrays
name1 = {:first_name => "Mike", :last_name => "McKinney"}
name2 = {:first_name => "Bo", :last_name => "Diddley"}
names = [name1, name2]

puts "--first names "
puts names.first_name
puts "--last names "
puts names.last_name
puts "--middle names "
puts names.middle_name
[/sourcecode]

Of course you would want to look a little closer at the implications this type of patch would have on your code, but it's sure nice how flexible ruby can be.

Tuesday, May 13, 2008

JavaOne '08 - Script Bowl apps for JRuby released

This year's JavaOne had an interesting competition... the Script Bowl.  Pitting 4 different languages (Groovy, Scala, Jython & JRuby) on the JVM against each other in three different categories.  (Rich Client Application, Web Application and an Open event)  Check the results here on Rags' blog.

Headius just posted the JRuby Script Bowl artifacts for your viewing pleasure.  Anyone know if the other languages have posted their apps/code?