Timing parsing the android_api.xml file vs reading in a marshalled string of the REXML object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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