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

  2. On 01/05/2012 04:18 AM, 罗晟 wrote:
    > 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
    Robert Klemme, Jan 5, 2012
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    276
    Tony Nelson
    Oct 15, 2005
  2. Replies:
    1
    Views:
    93
  3. Ruby Maniac
    Replies:
    57
    Views:
    593
    Chad Perrin
    Sep 27, 2007
  4. Replies:
    35
    Views:
    329
    Uri Guttman
    May 18, 2008
  5. Replies:
    18
    Views:
    172
    Michael Torrie
    Jul 21, 2013
Loading...

Share This Page