diff options
author | Frank Barchard <fbarchard@google.com> | 2015-11-03 17:01:48 -0800 |
---|---|---|
committer | Frank Barchard <fbarchard@google.com> | 2015-11-03 17:01:48 -0800 |
commit | c629cb3afedfbd8c88c92891b5b843db2ad9aba2 (patch) | |
tree | 1ddde8dbf66af1156e1cb0dc43744272315d9bf3 /unit_test/unit_test.cc | |
parent | 1f1d140bb6b15360219e2746f83f13f73e95169f (diff) | |
download | libyuv-c629cb3afedfbd8c88c92891b5b843db2ad9aba2.tar.gz |
add command line cpu info to allow android neon test
in order to compare C and Neon code, a new command line flag is added.
historically environment variables controlled cpu features, but on
android apk it is easier to pass a command line option to disable cpu
optimizations.
R=harryjin@google.com
BUG=libyuv:516
Review URL: https://codereview.chromium.org/1407193009 .
Diffstat (limited to 'unit_test/unit_test.cc')
-rw-r--r-- | unit_test/unit_test.cc | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index fb29c257..c6febf87 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -27,6 +27,8 @@ DEFINE_int32(libyuv_width, 0, "width of test image."); DEFINE_int32(libyuv_height, 0, "height of test image."); DEFINE_int32(libyuv_repeat, 0, "number of times to repeat test."); DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 0 = C -1 = asm"); +DEFINE_int32(libyuv_cpu_info, -1, + "cpu flags for benchmark code. -1 = SIMD, 1 = C"); // For quicker unittests, default is 128 x 72. But when benchmarking, // default to 720p. Allow size to specify. @@ -34,7 +36,7 @@ DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 0 = C -1 = asm"); LibYUVConvertTest::LibYUVConvertTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(130), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -67,6 +69,13 @@ LibYUVConvertTest::LibYUVConvertTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * @@ -79,7 +88,7 @@ LibYUVConvertTest::LibYUVConvertTest() : LibYUVColorTest::LibYUVColorTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -112,6 +121,13 @@ LibYUVColorTest::LibYUVColorTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * @@ -124,7 +140,7 @@ LibYUVColorTest::LibYUVColorTest() : LibYUVScaleTest::LibYUVScaleTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -157,6 +173,13 @@ LibYUVScaleTest::LibYUVScaleTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * @@ -169,7 +192,7 @@ LibYUVScaleTest::LibYUVScaleTest() : LibYUVRotateTest::LibYUVRotateTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -202,6 +225,13 @@ LibYUVRotateTest::LibYUVRotateTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * @@ -214,7 +244,7 @@ LibYUVRotateTest::LibYUVRotateTest() : LibYUVPlanarTest::LibYUVPlanarTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -247,6 +277,13 @@ LibYUVPlanarTest::LibYUVPlanarTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * @@ -259,7 +296,7 @@ LibYUVPlanarTest::LibYUVPlanarTest() : LibYUVBaseTest::LibYUVBaseTest() : benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), - benchmark_height_(72), disable_cpu_flags_(0) { + benchmark_height_(72), disable_cpu_flags_(0), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT @@ -292,6 +329,13 @@ LibYUVBaseTest::LibYUVBaseTest() : if (FLAGS_libyuv_flags) { disable_cpu_flags_ = FLAGS_libyuv_flags; } + const char* cpu_info = getenv("LIBYUV_CPU_INFO"); + if (cpu_info) { + benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT + } + if (FLAGS_libyuv_cpu_info) { + benchmark_cpu_info_ = FLAGS_libyuv_cpu_info; + } benchmark_pixels_div256_ = static_cast<int>(( static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_height_)) * |