[xml] Profiling and possible speed improvements



Hi folks,

My xslt stylesheet took a bit long to apply (many hours, but amongst other 
things it creates an index of my document, which is probably a bit of a
stretch to do with xslt), so I profiled it with gprof to see where it
spent its time. It seems that most time is consumed within xmlXPathCmpNodes,
which in turn is called from xmlXPathNodeSetSort. As this uses a Shell
sort algorithm, and it seems that I am handling somewhat large nodesets,
I wondered whether it would help to use another sorting algorithm (with
a little luck, that would reduce the number of node comparisons needed). 
To keep it simple, I tried the qsort algorithm of glibc-2.2.5, which
indeed uses a quick-sort. This seemed to help quite a lot.

I have attached the diff I used to illustrate the changes needed. 
Basically, I created xmlXPathCmpNodes_qsort that does the same job
as xmlXPathCmpNodes, except that it conforms to qsort semantics
(don't return -2, -1 means less than, use pointers to elements).
Don't apply this blindly, it needs some more work.

Thanks for the good work,
   Frodo

-- 
Frodo Looijaard <frodol dds nl>  PGP key and more: http://huizen.dds.nl/~frodol
Defenestration n. (formal or joc.):
  The act of removing Windows from your computer in disgust, usually followed
  by the installation of Linux or some other Unix-like operating system.

Attachment: libxml2-qsort.diff
Description: 'diff' output text



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]