[FFmpeg-cvslog] base64: Only run benchmark when "-t" is specified.

Michael Niedermayer git at videolan.org
Sat Jan 21 05:40:32 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jan 21 05:11:19 2012 +0100| [bdd739e91cf30a016cba1461170a01b231e54785] | committer: Michael Niedermayer

base64: Only run benchmark when "-t" is specified.

As the test is run during fate and the benchmark is useless for fate
this very slightly speeds up fate. Its also consistent with the other
tests.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdd739e91cf30a016cba1461170a01b231e54785
---

 libavutil/base64.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavutil/base64.c b/libavutil/base64.c
index b5034d3..af4a420 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -150,7 +150,7 @@ static int test_encode_decode(const uint8_t *data, unsigned int data_size,
     return 0;
 }
 
-int main(void)
+int main(int argc, char ** argv)
 {
     int i, error_count = 0;
     struct test {
@@ -172,22 +172,24 @@ int main(void)
     for (i = 0; i < FF_ARRAY_ELEMS(tests); i++)
         error_count += test_encode_decode(tests[i].data, strlen(tests[i].data), tests[i].encoded_ref);
 
-    memset(in, 123, sizeof(in));
-    for(i=0; i<10000; i++){
-        START_TIMER
-        av_base64_encode(out, sizeof(out), in, sizeof(in));
-        STOP_TIMER("encode")
-    }
-    for(i=0; i<10000; i++){
-        START_TIMER
-        av_base64_decode(in, out, sizeof(in));
-        STOP_TIMER("decode")
-    }
+    if (argc>1 && !strcmp(argv[1], "-t")) {
+        memset(in, 123, sizeof(in));
+        for(i=0; i<10000; i++){
+            START_TIMER
+            av_base64_encode(out, sizeof(out), in, sizeof(in));
+            STOP_TIMER("encode")
+        }
+        for(i=0; i<10000; i++){
+            START_TIMER
+            av_base64_decode(in, out, sizeof(in));
+            STOP_TIMER("decode")
+        }
 
-    for(i=0; i<10000; i++){
-        START_TIMER
-        av_base64_decode(NULL, out, 0);
-        STOP_TIMER("syntax check")
+        for(i=0; i<10000; i++){
+            START_TIMER
+            av_base64_decode(NULL, out, 0);
+            STOP_TIMER("syntax check")
+        }
     }
 
     return error_count;



More information about the ffmpeg-cvslog mailing list