how to make my ruby code faster?

Ç

罗晟

hi there, I just write a ruby program mirror to its python version to
feel the difference between the two fantastic language. here is the
ruby code. http://paste.pocoo.org/show/530185/. But I found it
twice slower(1.09 seconds to run) than its python counterpart(0.34
seconds to run). I think I made some mistake in writing this ruby
code. How can I make the ruby code faster? I'm using MRI 1.9.2, and
the file 0103.log is a 60000 lines file.
 
R

Robert Klemme

hi there, I just write a ruby program mirror to its python version to
feel the difference between the two fantastic language. here is the
ruby code. http://paste.pocoo.org/show/530185/. But I found it
twice slower(1.09 seconds to run) than its python counterpart(0.34
seconds to run). I think I made some mistake in writing this ruby
code. How can I make the ruby code faster? I'm using MRI 1.9.2, and
the file 0103.log is a 60000 lines file.

I don't have a mysql handy nor can I afford the time to set up one right
now. Also it's hard without documentation and explanation what the code
is supposed to do. You could start though with replacing your include?
chek in is_bad with a regexp match. I can see a few more micro
optimizations but it's better to first tackle the overall design. Did
you try running with "ruby -r profile"?

Cheers

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top