Function parser for C++: Speed tests

These tests were performed by running each specific test many times in a loop and then averaging the total time with the number of loops performed. The parsing, evaluation, evaluation after optimization, and optimization speeds were measured. The time is specified in microseconds (µs).

(Note that the actual speeds may vary more than the amount of used significant digits in the list below from execution to execution. The most significant digit is nevertheless quite accurate.)

These tests were run with the version 4.0.2 of the FunctionParser library.

Test platform 1

The following results were obtained on a 3.4GHz Pentium4 using gcc 4.3.1 with the compiler options -O3 -ffast-math -march=native


Function: "x^14 + y^8"


Function: "((3*x^4-7*x^3+2*x^2-4*x+10) - (4*y^3+2*y^2-10*y+2))*10"


Function: "((3*(x+(5*(y+2)-7*x)*3-y)+4*5+3)-7+(8*x+5*y+(7-x))*4)-10*3+4"


Function: "(tan(x)*cos(x))^2 - 1.2*log(atan2(sqrt((-y^2)+1), y) * 4.91^y) + cos(-x)^2"


Function: "exp((-x*x-y*y)/100)*sin(sqrt(x*x+y*y))/(10*2) + sin(pow(x,4)-4*pow(x,3)+3*x*x-2*x+2*5-3) - cos(-2*pow(y,4)+5*pow(y,3)-14*x*x+8*x-120/2+4)"


Test platform 2

The following results were obtained on a 2.4GHz Intel Core2 Quad using gcc 4.3.4


Function: "x^14 + y^8"


Function: "((3*x^4-7*x^3+2*x^2-4*x+10) - (4*y^3+2*y^2-10*y+2))*10"


Function: "((3*(x+(5*(y+2)-7*x)*3-y)+4*5+3)-7+(8*x+5*y+(7-x))*4)-10*3+4"


Function: "(tan(x)*cos(x))^2 - 1.2*log(atan2(sqrt((-y^2)+1), y) * 4.91^y) + cos(-x)^2"


Function: "exp((-x*x-y*y)/100)*sin(sqrt(x*x+y*y))/(10*2) + sin(pow(x,4)-4*pow(x,3)+3*x*x-2*x+2*5-3) - cos(-2*pow(y,4)+5*pow(y,3)-14*x*x+8*x-120/2+4)"