Added buildbot benchmarking in iSAC and APM into Android platform build.
Review URL: https://webrtc-codereview.appspot.com/964022

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3247 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/audio_coding/codecs/isac/fix/source/Android.mk b/modules/audio_coding/codecs/isac/fix/source/Android.mk
index e7745ea..888fbd8 100644
--- a/modules/audio_coding/codecs/isac/fix/source/Android.mk
+++ b/modules/audio_coding/codecs/isac/fix/source/Android.mk
@@ -119,7 +119,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES:= ../test/kenny.c
+LOCAL_SRC_FILES:= ../test/kenny.cc
 
 # Flags passed to both C and C++ files.
 LOCAL_CFLAGS := $(MY_WEBRTC_COMMON_DEFS)
@@ -131,7 +131,8 @@
 LOCAL_STATIC_LIBRARIES := \
     libwebrtc_isacfix \
     libwebrtc_spl \
-    libwebrtc_system_wrappers
+    libwebrtc_system_wrappers \
+    libwebrtc_test_support
 
 ifeq ($(WEBRTC_BUILD_NEON_LIBS),true)
 LOCAL_STATIC_LIBRARIES += \
diff --git a/modules/audio_coding/codecs/isac/fix/test/kenny.c b/modules/audio_coding/codecs/isac/fix/test/kenny.cc
similarity index 97%
rename from modules/audio_coding/codecs/isac/fix/test/kenny.c
rename to modules/audio_coding/codecs/isac/fix/test/kenny.cc
index b7ca694..d95dea9 100644
--- a/modules/audio_coding/codecs/isac/fix/test/kenny.c
+++ b/modules/audio_coding/codecs/isac/fix/test/kenny.cc
@@ -8,16 +8,17 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-/* kenny.c  - Main function for the iSAC coder */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <ctype.h>
 
-#include "isacfix.h"
+#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
+#include "webrtc/test/testsupport/perf_test.h"
 
+// TODO(kma): Clean up the code and change benchmarking the whole codec to
+// separate encoder and decoder.
 
 /* Defines */
 #define SEED_FILE "randseed.txt"  /* Used when running decoder on garbage data */
@@ -170,7 +171,7 @@
            " in adaptive mode.\n\n");
     printf("[-FL num]        :Set (initial) frame length in msec. Valid length"
            " are 30 and 60 msec.\n\n");
-    printf("[-FIXED_FL]      :Frame length will be fixed to initial value.\n\n");
+    printf("[-FIXED_FL]      :Frame length to be fixed to initial value.\n\n");
     printf("[-MAX num]       :Set the limit for the payload size of iSAC"
            " in bytes. \n");
     printf("                  Minimum 100, maximum 400.\n\n");
@@ -374,7 +375,8 @@
     sscanf(argv[CodingMode+1], "%s", bottleneck_file);
     f_bn = fopen(bottleneck_file, "rb");
     if (f_bn  == NULL) {
-      printf("No value provided for BottleNeck and cannot read file %s\n", bottleneck_file);
+      printf("No value provided for BottleNeck and cannot read file %s\n",
+             bottleneck_file);
       exit(0);
     } else {
       int aux_var;
@@ -565,8 +567,8 @@
                                             shortdata,
                                             (WebRtc_Word16*)streamdata);
 
-          /* If packet is ready, and CE testing, call the different API functions
-             from the internal API.                       */
+          /* If packet is ready, and CE testing, call the different API
+             functions from the internal API. */
           if (stream_len>0) {
             if (testCE == 1) {
               err = WebRtcIsacfix_ReadBwIndex((WebRtc_Word16*)streamdata, &bwe);
@@ -808,6 +810,10 @@
          runtime, (100*runtime/length_file));
   printf("\n\n_______________________________________________\n");
 
+  // Record the results with Perf test tools.
+  webrtc::test::PrintResult("time_per_10ms_frame", "", "isac",
+                            (runtime * 10000) / length_file, "us", false);
+
   fclose(inp);
   fclose(outp);
   fclose(outbits);
diff --git a/modules/audio_coding/codecs/isac/isacfix_test.gypi b/modules/audio_coding/codecs/isac/isacfix_test.gypi
index e1e1311..ce2f46c 100644
--- a/modules/audio_coding/codecs/isac/isacfix_test.gypi
+++ b/modules/audio_coding/codecs/isac/isacfix_test.gypi
@@ -14,13 +14,14 @@
       'type': 'executable',
       'dependencies': [
         'iSACFix',
+        '<(webrtc_root)/test/test.gyp:test_support',
       ],
       'include_dirs': [
         './fix/test',
         './fix/interface',
       ],
       'sources': [
-        './fix/test/kenny.c',
+        './fix/test/kenny.cc',
       ],
     },
   ],
diff --git a/modules/audio_processing/Android.mk b/modules/audio_processing/Android.mk
index 201b23a..7e87751 100644
--- a/modules/audio_processing/Android.mk
+++ b/modules/audio_processing/Android.mk
@@ -89,6 +89,7 @@
 
 LOCAL_STATIC_LIBRARIES := \
     libgtest \
+    libwebrtc_test_support \
     libprotobuf-cpp-2.3.0-lite
 
 LOCAL_SHARED_LIBRARIES := \
@@ -113,8 +114,7 @@
 LOCAL_CPP_EXTENSION := .cc
 LOCAL_SRC_FILES:= \
     $(call all-proto-files-under, test) \
-    test/unit_test.cc \
-    ../../test/testsupport/fileutils.cc
+    test/unit_test.cc
 
 # Flags passed to both C and C++ files.
 LOCAL_CFLAGS := \
@@ -136,6 +136,7 @@
 
 LOCAL_STATIC_LIBRARIES := \
     libgtest \
+    libwebrtc_test_support \
     libprotobuf-cpp-2.3.0-lite
 
 LOCAL_SHARED_LIBRARIES := \
diff --git a/modules/audio_processing/audio_processing_tests.gypi b/modules/audio_processing/audio_processing_tests.gypi
index 0d5bfac..323a457 100644
--- a/modules/audio_processing/audio_processing_tests.gypi
+++ b/modules/audio_processing/audio_processing_tests.gypi
@@ -58,8 +58,9 @@
           'dependencies': [
             'audio_processing',
             'audioproc_debug_proto',
-            '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
             '<(DEPTH)/testing/gtest.gyp:gtest',
+            '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
+            '<(webrtc_root)/test/test.gyp:test_support',
           ],
           'sources': [ 'test/process_test.cc', ],
         },
diff --git a/modules/audio_processing/test/process_test.cc b/modules/audio_processing/test/process_test.cc
index e68d1e9..70c4b15 100644
--- a/modules/audio_processing/test/process_test.cc
+++ b/modules/audio_processing/test/process_test.cc
@@ -19,11 +19,12 @@
 
 #include "gtest/gtest.h"
 
-#include "audio_processing.h"
-#include "cpu_features_wrapper.h"
-#include "module_common_types.h"
-#include "scoped_ptr.h"
-#include "tick_util.h"
+#include "webrtc/modules/audio_processing/include/audio_processing.h"
+#include "webrtc/modules/interface/module_common_types.h"
+#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
+#include "webrtc/system_wrappers/interface/scoped_ptr.h"
+#include "webrtc/system_wrappers/interface/tick_util.h"
+#include "webrtc/test/testsupport/perf_test.h"
 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
 #else
@@ -1032,6 +1033,9 @@
           (exec_time * 1.0) / primary_count,
           (max_time_us + max_time_reverse_us) / 1000.0,
           (min_time_us + min_time_reverse_us) / 1000.0);
+      // Record the results with Perf test tools.
+      webrtc::test::PrintResult("time_per_10ms_frame", "", "audioproc",
+          (exec_time * 1000) / primary_count, "us", false);
     } else {
       printf("Warning: no capture frames\n");
     }
diff --git a/test/Android.mk b/test/Android.mk
new file mode 100644
index 0000000..20af6f9
--- /dev/null
+++ b/test/Android.mk
@@ -0,0 +1,39 @@
+
+# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+include $(LOCAL_PATH)/../../android-webrtc.mk
+
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE:= libwebrtc_test_support
+LOCAL_MODULE_TAGS := optional
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES:= \
+    testsupport/fileutils.cc \
+    testsupport/perf_test.cc
+
+# Flags passed to both C and C++ files.
+LOCAL_CFLAGS := \
+    $(MY_WEBRTC_COMMON_DEFS)
+
+LOCAL_C_INCLUDES := \
+    external/gtest/include \
+    external/webrtc \
+    external/webrtc/webrtc
+
+LOCAL_STATIC_LIBRARIES := \
+    libgtest
+
+ifndef NDK_ROOT
+include external/stlport/libstlport.mk
+endif
+include $(BUILD_STATIC_LIBRARY)
+