Ruby Hash/Array to_yaml is slow

S

Shin guey Wong

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?
 
R

Ryan Davis

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top