Skip to content

Instantly share code, notes, and snippets.

@jackowayed
Created November 28, 2010 00:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jackowayed/718417 to your computer and use it in GitHub Desktop.
Timing parsing the android_api.xml file vs reading in a marshalled string of the REXML object.
~/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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment