how to make my ruby code faster?

Discussion in 'Ruby' started by 罗晟, Jan 5, 2012.

  1. 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. 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.
    罗晟, Jan 5, 2012
    1. Advertisements

  2. 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"?


    Robert Klemme, Jan 5, 2012
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.