Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Last active August 29, 2015 14:24
Show Gist options
  • Save jcoyne/a62a66390ac6f4128a2c to your computer and use it in GitHub Desktop.
Save jcoyne/a62a66390ac6f4128a2c to your computer and use it in GitHub Desktop.
def find_klass_for_id(id)
query = "id\:#{RSolr.solr_escape(id)}"
solr_doc = ActiveFedora::SolrService.query(query).first
raise ActiveFedora::ObjectNotFoundError("Unable to find '#{id}'") if solr_doc.nil?
klass = ActiveFedora::QueryResultBuilder.class_from_solr_document(solr_doc)
"#{klass}:#{id}"
end
n = 5000
Benchmark.bm do |x|
x.report { for i in 1..n; find_klass_for_id("f3/gt/5k/61/f3gt5k61"); end }
end
user system total real
8.250000 2.090000 10.340000 ( 26.949549)
Benchmark.bm do |x|
x.report { for i in 1..n; ActiveFedora::Base.load_instance_from_solr("f3/gt/5k/61/f3gt5k61"); end }
end
user system total real
31.290000 2.140000 33.430000 ( 50.431472)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment