[SOLUTION] Index and Query (#54)

Discussion in 'Ruby' started by Daniel Sheppard, Nov 15, 2005.

  1. My solution is here:

    http://members.iinet.net.au/~soxbox/ruby_quiz_54/indexer.rb

    And also a script that benchmarks it against grepping the files manually
    (My first attempts ended up being slower... eeep):

    http://members.iinet.net.au/~soxbox/ruby_quiz_54/indexer_bm.rb

    I used shakespeare's sonnets from project gutenburg to do the testing.=20

    Results:

    =20 user system total real
    first word 0.157000 0.047000 0.204000 ( 0.219000)
    median word 0.109000 0.046000 0.155000 ( 0.156000)
    last word 0.141000 0.063000 0.204000 ( 0.203000)
    index last word 0.062000 0.000000 0.062000 ( 0.063000)
    non-existant 0.063000 0.000000 0.063000 ( 0.062000)
    grep first 1.656000 1.453000 3.109000 ( 3.625000)
    grep median 1.969000 1.438000 3.407000 ( 3.438000)
    grep last 2.343000 1.140000 3.483000 ( 4.125000)

    And, if I take out the indexing of the word list file (which wont occur
    if you use it from the commandline):

    =20 user system total real
    first word 0.562000 0.078000 0.640000 ( 0.687000)
    median word 0.547000 0.047000 0.594000 ( 0.703000)
    last word 0.547000 0.078000 0.625000 ( 1.000000)
    index last word 0.469000 0.000000 0.469000 ( 0.500000)
    non-existant 0.468000 0.031000 0.499000 ( 0.500000)
    grep first 1.875000 1.219000 3.094000 ( 3.219000)
    grep median 1.875000 1.250000 3.125000 ( 3.188000)
    grep last 1.813000 1.344000 3.157000 ( 3.203000)


    #########################################################################=
    ############
    This email has been scanned by MailMarshal, an email content filter.
    #########################################################################=
    ############
     
    Daniel Sheppard, Nov 15, 2005
    #1
    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. karthikeyavenkat
    Replies:
    2
    Views:
    644
    Bryce
    Mar 17, 2005
  2. Zed Lopez
    Replies:
    0
    Views:
    87
    Zed Lopez
    Nov 17, 2005
  3. Shawn W_
    Replies:
    5
    Views:
    310
    Aldric Giacomoni
    Sep 16, 2009
  4. ngoc
    Replies:
    5
    Views:
    194
    Tad McClellan
    May 11, 2006
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    334
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page