Skip to content

Instantly share code, notes, and snippets.

@billdueber
Created September 22, 2010 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billdueber/591745 to your computer and use it in GitHub Desktop.
Save billdueber/591745 to your computer and use it in GitHub Desktop.
$:.unshift 'lib'
require 'marc'
require 'benchmark'
require 'profiler'
tags = ['001','005', '100','110','111','240','243','245', /^6[0-9][0-9]$/, '700', '710', '711']
rec = MARC::Reader.new('batch.dat').first
1000.times do
tags.each do |tag|
if tag.is_a?(String)
t = rec.fields(tag)
else
t = rec.find_all { | f | f.tag =~ tag }
end
end
end
# %self total self wait child calls name
# 23.10 0.97 0.51 0.00 0.46 11001 Array#hash
# 20.69 0.46 0.46 0.00 0.00 198018 Kernel#hash
# 18.19 1.71 0.40 0.00 1.31 11000 MARC::Record#fields
# 15.58 2.12 0.35 0.00 1.96 6030 Array#each
# 4.83 1.11 0.11 0.00 1.00 11000 MARC::FieldMap#in_sync?
# 4.11 0.09 0.09 0.00 0.00 37003 Kernel#is_a?
# 3.75 0.09 0.08 0.00 0.08 93 Kernel#gem_original_require
# 2.59 0.08 0.06 0.00 0.02 15055 Hash#[]
# 2.50 0.06 0.06 0.00 0.00 18000 String#=~
# 1.24 0.03 0.03 0.00 0.00 11000 Fixnum#==
# 0.79 0.02 0.02 0.00 0.00 7037 Hash#default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment