forked from FFmpeg/FFmpeg
simplify
benchmark Originally committed as revision 3844 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
fdb86eb10d
commit
80a4995853
1 changed files with 15 additions and 14 deletions
|
@ -143,13 +143,9 @@ static double evalPrimary(Parser *p){
|
||||||
}
|
}
|
||||||
|
|
||||||
static double evalPow(Parser *p){
|
static double evalPow(Parser *p){
|
||||||
if(p->s[0]=='+') p->s++;
|
int sign= (*p->s == '+') - (*p->s == '-');
|
||||||
|
p->s += sign&1;
|
||||||
if(p->s[0]=='-'){
|
return (sign|1) * evalPrimary(p);
|
||||||
p->s++;
|
|
||||||
return -evalPrimary(p);
|
|
||||||
}else
|
|
||||||
return evalPrimary(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static double evalFactor(Parser *p){
|
static double evalFactor(Parser *p){
|
||||||
|
@ -171,17 +167,15 @@ static double evalTerm(Parser *p){
|
||||||
}
|
}
|
||||||
|
|
||||||
static double evalExpression(Parser *p){
|
static double evalExpression(Parser *p){
|
||||||
double ret;
|
double ret= 0;
|
||||||
|
|
||||||
if(p->stack_index <= 0) //protect against stack overflows
|
if(p->stack_index <= 0) //protect against stack overflows
|
||||||
return NAN;
|
return NAN;
|
||||||
p->stack_index--;
|
p->stack_index--;
|
||||||
|
|
||||||
ret= evalTerm(p);
|
do{
|
||||||
while(p->s[0]=='+' || p->s[0]=='-'){
|
ret += evalTerm(p);
|
||||||
if(*p->s++ == '+') ret+= evalTerm(p);
|
}while(*p->s == '+' || *p->s == '-');
|
||||||
else ret-= evalTerm(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->stack_index++;
|
p->stack_index++;
|
||||||
|
|
||||||
|
@ -220,6 +214,13 @@ static const char *const_names[]={
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
main(){
|
main(){
|
||||||
|
int i;
|
||||||
printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL));
|
printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL));
|
||||||
|
|
||||||
|
for(i=0; i<1050; i++){
|
||||||
|
START_TIMER
|
||||||
|
ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
STOP_TIMER("ff_eval")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue