Posteado por: emmanueloga en: Marzo 5, 2008
Exploring two different libraries for pdf generation on ruby I found that they both have the same example (demo.rb) generating the same results (at least to my eyes
. One was the venerable PDF::Writer library, the other libharu2.
Here. Have some benchmarks on demo.rb:
#Rehearsal -------------------------------------------------------------------- #PDF Writer 100 times 18.984000 0.547000 19.531000 ( 19.616000) #Haru 2 100 times 0.235000 0.281000 0.516000 ( 0.517000) #PDF Writer saving file 100 times 18.531000 0.391000 18.922000 ( 19.836000) #Haru2 saving file 100 times 0.250000 0.375000 0.625000 ( 0.688000) #---------------------------------------------------------- total: 39.594000sec #user system total real #PDF Writer 100 times 18.500000 0.265000 18.765000 ( 18.866000) #Haru 2 100 times 0.156000 0.344000 0.500000 ( 0.500000) #PDF Writer saving file 100 times 18.703000 0.203000 18.906000 ( 19.336000) #Haru2 saving file 100 times 0.172000 0.407000 0.579000 ( 0.657000)
In this microbenchmark, libharu2 is almost 40 times faster than PDF::Writer !!! Because I think that libharu2 is very useful, I packaged it as a gem on rubyforge. Try it:
“sudo gem install hpdf“
Don’t forget to require ‘rubygems’ on your programs before requiring hpdf
HPDF TODO: Documentation, helpers (for example: no table drawer yet). I have only packaged the gem, didn’t add anything to it.
Thanks a lot!
Julio 23, 2008 a 5:58 pm
Is possible to use haru in Ruport pdf formatter instead of pdf_writer?