Ruby Hash/Array to_yaml is slow

I try to convert a ruby array(contains hash and array) to yaml and it
takes 60 seconds to perform the job and it consumes a lot of memory and
full cpu usage(almost 100%). The ruby object is very big and it will
produce 80000+ lines of yaml file. The speed is not acceptable for me.
So, instead of using the to_yaml function I created my own conversion
function just do print string for the hash and the array and now it only
take 2 seconds.(I did some changes like use inner hash to reduce the
yaml lines count, now it only produce 40000 lines) I am not sure the
alogrithm of the yaml but could it be a bug for the ruby yaml?

On May 2, 2008, at 22:57 , Shin guey Wong wrote:

I am not sure the
alogrithm of the yaml but could it be a bug for the ruby yaml?

if it is, this isn’t the right forum to report it. File a bug on
_why’s trac.

Alternatively, use Marshal.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs