A
Ara.T.Howard
is there anything that can be done to improve this? i'd like to use yaml for
this project but...
~ > cat test.rb
require 'yaml/store'
require 'pstore'
def time label
a = Time.now
ret = yield
b = Time.now
puts "#{ label } @ #{ b.to_f - a.to_f }"
ret
end
obj = Array.new(65536).map!{{'time'=>Time.now,'rand'=>rand}}
pstore = PStore.new 'pstore.db'
yamlstore = YAML::Store.new 'yaml.db'
time("pstore dump time") do
pstore.transaction{|db| db['obj'] = obj}
end
time("pstore load time") do
o = pstore.transaction{|db| db['obj']}
end
time("yamlstore dump time") do
yamlstore.transaction{|db| db['obj'] = obj}
end
time("yamlstore load time") do
o = yamlstore.transaction{|db| db['obj']}
end
File.unlink 'pstore.db'
File.unlink 'yaml.db'
~ > ruby test.rb
pstore dump time @ 0.988970994949341
pstore load time @ 1.86728405952454
yamlstore dump time @ 42.3903992176056
yamlstore load time @ 47.6173989772797
ouch!
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
this project but...
~ > cat test.rb
require 'yaml/store'
require 'pstore'
def time label
a = Time.now
ret = yield
b = Time.now
puts "#{ label } @ #{ b.to_f - a.to_f }"
ret
end
obj = Array.new(65536).map!{{'time'=>Time.now,'rand'=>rand}}
pstore = PStore.new 'pstore.db'
yamlstore = YAML::Store.new 'yaml.db'
time("pstore dump time") do
pstore.transaction{|db| db['obj'] = obj}
end
time("pstore load time") do
o = pstore.transaction{|db| db['obj']}
end
time("yamlstore dump time") do
yamlstore.transaction{|db| db['obj'] = obj}
end
time("yamlstore load time") do
o = yamlstore.transaction{|db| db['obj']}
end
File.unlink 'pstore.db'
File.unlink 'yaml.db'
~ > ruby test.rb
pstore dump time @ 0.988970994949341
pstore load time @ 1.86728405952454
yamlstore dump time @ 42.3903992176056
yamlstore load time @ 47.6173989772797
ouch!
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================