From: Nadezda Sekret on 19 Jun 2010 03:33 Hello! I wrote ruby script, which parse 2 XML files and compare them using libxml-ruby. If difference is found - puts message about it. But this script works long. I am new in ruby and don't know how to change it, maybe someone can help me to improve my script? I am parsing large XML files. (~30M) My script is in attachment. Thank You! Attachments: http://www.ruby-forum.com/attachment/4812/diffscript.rb -- Posted via http://www.ruby-forum.com/.
From: Intransition on 19 Jun 2010 11:28 On Jun 19, 3:33 am, Nadezda Sekret <nadja...(a)inbox.lv> wrote: > Hello! > > I wrote ruby script, which parse 2 XML files and compare them using > libxml-ruby. If difference is found - puts message about it. > But this script works long. I am new in ruby and don't know how to > change it, maybe someone can help me to improve my script? > I am parsing large XML files. (~30M) > My script is in attachment. > > Thank You! First of a couple of pointers. * Indent two spaces. That is the Ruby common practice and will make your code easier to read. (If don't like such shallow indention then use 4, but please 8 is just too much). * Post large samples like this to snippets sites such as github's gist (http://gist.github.com/) it will colorize the output nicely, again making it easier to read. * Add some comments to the code to explain what is going on. People not familiar with libxml-ruby might be able to help if they knew how XML::Reader worked. Having said that, you might get better performance if you eliminate where the two documents are the same, then what is left over will be their differences. Just a thought.
|
Pages: 1 Prev: [ANN] easy_translate-0.1.1 Next: MAKE UPTO $5000 PER MONTH! $2000 IN FIRST 30 DAYS! |