Closed mariuszgromada closed 1 year ago
Hi @mariuszgromada thanks for noticing!
Yep, I've already used pre-compilation)
protected void CalcMxParser(string formula)
{
var expression = CreateMxParser(formula);
expression.calculate();
for (var i = 0; i < N; i++)
{
expression.calculate();
}
}
Surprisingly in MathParser.org-mXparser I found interesting performance leak without smart route disabling:
for example:
version 5.0.6 | Formula1_MxParser | 225.4 ms version 5.0.7 | Formula1_MxParser | 672.1 ms version 5.2.0 | Formula1_MxParser | 694.5 ms
but when I disable routing:
mXparser.disableAlmostIntRounding();
mXparser.disableUlpRounding();
mXparser.disableCanonicalRounding();
version 5.2.0 | Formula1_MxParser | 182.8 ms
Will create MR and share the results later, thanks!
Great, congrats for the lib! :-)
5.0.7 if I remember correctly (but I am unsure) was a re-work on calculation steps register :-) Please take a look https://mathparser.org/mxparser-tutorial/calculation-steps-register/
Hi @mariuszgromada, I updated benchmark as you've written, now x8 faster, not x9 :)
I've added rounding disabling here Take a look please is benchmark correct?
Thanks! You motivated me to make some performance improvements. I have a sloppy loop statemented that is O(n) inside of O(n), finally I get O(n^2). This is why longer expressions are penalized more :-)
I will make some changes later :-)
Great to hear that! Raring to see the new version :)
So new version has just been published, can you test it now? :-)
NuGet\Install-Package MathParser.org-mXparser -Version 5.2.1
Awesome! Will test a bit later :)
@mariuszgromada perfect results, now I'm only x4 faster! But mXparser became slower almost twice in formula9 (compared with previous version)
@KovtunV exactly, to improve performance more (especially for the IF function) I have to think a bit longer. But still I did quite significant improvement :-)
Your lib works great, congrats!
@mariuszgromada thank you) should I merge it into the master or wait for the next improvements?
Please merge :-)
Hi,
Many thanks for the lib and the benchmark. mXparser does not fight strictly for the performance - the main focus is the functionality. Anyway it is a great comparison. Before running the benchmark always turn off all the smart rounding settings - especially the canonical option is very heavy.
Please see more here: https://mathparser.org/mxparser-tutorial/smart-rounding-settings/ And here: https://mathparser.org/mxparser-tutorial/efficient-calculations-in-loops/ And here: https://mathparser.org/mxparser-tutorial/expression-pre-compilation/
Best regards :-)