dparser icon indicating copy to clipboard operation
dparser copied to clipboard

Speed of dparser -- possibly increase with std::sort from C++?

Open mattfidler opened this issue 5 years ago • 3 comments

For very long parsing blocks, the speed of dparser is long; See:

https://github.com/nlmixrdevelopment/RxODE/issues/61#issuecomment-456632859

The slowest function is here:

https://github.com/jplevyak/dparser/blob/98ae9ccd251c36c61a5ff2651e5c7ee1d0057ed3/parse.c#L854-L897

Which uses qsort

https://github.com/jplevyak/dparser/blob/98ae9ccd251c36c61a5ff2651e5c7ee1d0057ed3/parse.c#L864

In theory C++'s std::sort is 250% to 1000% faster and since you can refer to c++ from c, do you think a wrapper for the std::sort would greatly increase the parsing time?

If so, do you think it is worthwhile to contaminate the pure C with C++?

mattfidler avatar Jul 10 '19 22:07 mattfidler

My personal opinion (which carries whatever weight you wish to assign to it :-) ) is that no, this is not worthwhile, because it would bring in a dependency on the C++ development and runtime environments. One thing I love about dparser is its minimal requirements; they make it easier to use / wrap dparser wherever you wish.

gonzus avatar Jul 28 '20 07:07 gonzus

You could also possibly use timsort which has some variants written in C.

mattfidler avatar Jul 29 '20 00:07 mattfidler

I just stumbled upon this inline variant of qsort in C: https://www.corpit.ru/mjt/qsort.html

froh avatar Mar 01 '22 15:03 froh