lucene-ruby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jamie Orchard-Hays <ja...@dangosaur.us>
Subject Re: quick jruby + solr benchmarks
Date Wed, 26 Nov 2008 00:13:26 GMT
So about 2x? Not bad. I wonder what running httperf against a simple  
app would show.


On Nov 25, 2008, at 6:04 PM, Matt Mitchell wrote:

> I'm starting to experiment with benchmarks/jruby + solr and just  
> wanted to
> get this out there -- getting ready for a week vacation :)
>
> In my solr-ruby 'refactoring' progress, I'm finding some interesting  
> results
> and will try to post in the next few weeks.
>
> This is jruby 1.1.4 and solr 1.3 (empty index) -- using the standard  
> Ruby
> "Benchmark" library.
>
> The script:
>
> #
>
> require 'java'
> require 'benchmark'
>
> solr_dist_root = File.expand_path(File.join(File.dirname(__FILE__),  
> '..',
> 'apache-solr-1.3.0'))
> solr_home = File.join(solr_dist_root, 'example', 'solr')
>
> def require_jars(dir)
>  jar_pattern = File.join(dir,"**", "*.jar")
>  jar_files = Dir.glob(jar_pattern)
>  jar_files.each {|jar_file| require jar_file}
> end
>
> def hash_to_params(hash_params)
>  import org.apache.solr.common.params.ModifiableSolrParams
>  query = ModifiableSolrParams.new
>  query.instance_eval do
>    alias _add add
>    def add(field, values)
>      _add(field.to_s, (values.is_a?(Array) ? values :
> [values]).to_java(:string))
>    end
>  end
>  hash_params.each_pair do |k,v|
>    query.add k, v
>  end
>  query
> end
>
> require_jars(File.join(solr_dist_root, "lib"))
> require_jars(File.join(solr_dist_root, "dist"))
>
> # HttpCommons
> def http_commons
>  @http_commons ||= (
>    import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
>    import org.apache.solr.common.params.MapSolrParams
>    solr = CommonsHttpSolrServer.new("http://localhost:8983/solr")
>  )
> end
>
> # EmbeddedSolrServer
> def embedded(solr_home)
>  @embedded ||= (
>    import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
>    import org.apache.solr.core.CoreContainer
>    import org.apache.solr.core.CoreDescriptor
>    import org.apache.solr.client.solrj.SolrQuery
>    core_name = 'main-core'
>    container = CoreContainer.new
>    descriptor = CoreDescriptor.new(container, core_name, solr_home)
>    core = container.create(descriptor)
>    container.register(core_name, core, false)
>    solr = EmbeddedSolrServer.new(container, core_name)
>  )
> end
>
> query = {'qt' => 'standard', 'q'=>'ipod', 'facet.field' => 'cat'}
> params = hash_to_params(query)
>
> max = 1000
>
> Benchmark.bm do |x|
>  x.report 'http commons' do
>    max.times do
>      http_commons.query(params)
>    end
>  end
>  x.report 'embedded' do
>    max.times do
>      embedded(solr_home).query(params)
>    end
>  end
> end
>
> # THE RESULTS
>
> # http commons
>    # 4.634000   0.000000   4.634000 (  4.633849)
>    # 4.454000   0.000000   4.454000 (  4.453764)
>    # 3.908000   0.000000   3.908000 (  3.907367)
>
> # embedded
>    # 2.152000   0.000000   2.152000 (  2.152226)
>    # 2.191000   0.000000   2.191000 (  2.191359)
>    # 2.083000   0.000000   2.083000 (  2.082696)


Mime
View raw message