eval: make timing optional in test program
authorMans Rullgard <mans@mansr.com>
Sun, 3 Jul 2011 18:34:10 +0000 (19:34 +0100)
committerMans Rullgard <mans@mansr.com>
Mon, 4 Jul 2011 09:26:21 +0000 (10:26 +0100)
Signed-off-by: Mans Rullgard <mans@mansr.com>
libavutil/eval.c

index 4bba343becd57cbc190e21763962d7cc58b6f486..8ce687df196d63f8095a9a1e0c6ec386707a281d 100644 (file)
@@ -533,6 +533,8 @@ int av_expr_parse_and_eval(double *d, const char *s,
 
 #ifdef TEST
 #undef printf
 
 #ifdef TEST
 #undef printf
+#include <string.h>
+
 static double const_values[] = {
     M_PI,
     M_E,
 static double const_values[] = {
     M_PI,
     M_E,
@@ -545,7 +547,7 @@ static const char *const_names[] = {
     0
 };
 
     0
 };
 
-int main(void)
+int main(int argc, char **argv)
 {
     int i;
     double d;
 {
     int i;
     double d;
@@ -617,13 +619,16 @@ int main(void)
                            NULL, NULL, NULL, NULL, NULL, 0, NULL);
     printf("%f == 0.931322575\n", d);
 
                            NULL, NULL, NULL, NULL, NULL, 0, NULL);
     printf("%f == 0.931322575\n", d);
 
-    for (i=0; i<1050; i++) {
-        START_TIMER
+    if (argc > 1 && !strcmp(argv[1], "-t")) {
+        for (i = 0; i < 1050; i++) {
+            START_TIMER;
             av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
                                    const_names, const_values,
                                    NULL, NULL, NULL, NULL, NULL, 0, NULL);
             av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
                                    const_names, const_values,
                                    NULL, NULL, NULL, NULL, NULL, 0, NULL);
-        STOP_TIMER("av_expr_parse_and_eval")
+            STOP_TIMER("av_expr_parse_and_eval");
+        }
     }
     }
+
     return 0;
 }
 #endif
     return 0;
 }
 #endif