public
Last active

Timing parsing the android_api.xml file vs reading in a marshalled string of the REXML object.

  • Download Gist
results
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
~/code/android/play ‹ruby-1.8.7› $ ruby time.rb
Time to parse with REXML:
11.168489
Time to read in marshalled REXML object:
5.896579
~/code/android/play ‹ruby-1.8.7› $ rvm use jruby
Using /Users/daniel/.rvm/gems/jruby-1.5.5
~/code/android/play ‹jruby-1.5.5› $ ruby time.rb
Time to parse with REXML:
7.991
Time to read in marshalled REXML object:
6.429
~/code/android/play ‹jruby-1.5.5› $ rvm use rbx
Using /Users/daniel/.rvm/gems/rbx-head
~/code/android/play ‹rbx-head› $ ruby time.rb
Time to parse with REXML:
1435.695334
Time to read in marshalled REXML object:
40.52364
~/code/android/play ‹rbx-head› $ rvm use 1.9.2
Using /Users/daniel/.rvm/gems/ruby-1.9.2-p0
~/code/android/play ‹ruby-1.9.2› $ ruby time.rb
Time to parse with REXML:
9.181685
Time to read in marshalled REXML object:
2.69393
time.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
def time
start = Time.now
yield
puts Time.now - start
end
 
require 'rexml/document'
 
puts "Time to parse with REXML:"
time do
@api = REXML::Document.new(File.read(File.expand_path("android_api.xml"))).root
end
 
File.open('dump', 'w') do |f|
f << Marshal.dump(@api)
end
 
puts "Time to read in marshalled REXML object:"
time do
@api2 = Marshal.load File.read('dump')
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.