Commit de6eca31 authored by fbarchard@google.com's avatar fbarchard@google.com

Change unittest to default to 1 iteration of each test. Can be change manually…

Change unittest to default to 1 iteration of each test.  Can be change manually to 1000 for benchmarking purposes.
BUG=77
TEST=build\release\libyuv_unittest.exe
Review URL: https://webrtc-codereview.appspot.com/768006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@336 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent d4164fb0
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 335 Version: 336
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 335 #define LIBYUV_VERSION 336
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -53,8 +53,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N##_OptVsC) { \ ...@@ -53,8 +53,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N##_OptVsC) { \
dst_argb_c, kStride, \ dst_argb_c, kStride, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
MaskCpuFlags(-1); \ MaskCpuFlags(-1); \
const int runs = 1000; \ for (int i = 0; i < benchmark_iterations_; ++i) { \
for (int i = 0; i < runs; ++i) { \
FMT_PLANAR##To##FMT_B(src_y, kWidth, \ FMT_PLANAR##To##FMT_B(src_y, kWidth, \
src_u, kWidth / SUBSAMP_X, \ src_u, kWidth / SUBSAMP_X, \
src_v, kWidth / SUBSAMP_X, \ src_v, kWidth / SUBSAMP_X, \
...@@ -127,8 +126,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N##_OptVsC) { \ ...@@ -127,8 +126,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N##_OptVsC) { \
dst_argb_c, kWidth * BPP_B, \ dst_argb_c, kWidth * BPP_B, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
MaskCpuFlags(-1); \ MaskCpuFlags(-1); \
const int runs = 1000; \ for (int i = 0; i < benchmark_iterations_; ++i) { \
for (int i = 0; i < runs; ++i) { \
FMT_PLANAR##To##FMT_B(src_y, kWidth, \ FMT_PLANAR##To##FMT_B(src_y, kWidth, \
src_uv, kWidth / SUBSAMP_X * 2, \ src_uv, kWidth / SUBSAMP_X * 2, \
dst_argb_opt, kWidth * BPP_B, \ dst_argb_opt, kWidth * BPP_B, \
...@@ -184,8 +182,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N##_OptVsC) { \ ...@@ -184,8 +182,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N##_OptVsC) { \
dst_v_c, kWidth / SUBSAMP_X, \ dst_v_c, kWidth / SUBSAMP_X, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
MaskCpuFlags(-1); \ MaskCpuFlags(-1); \
const int runs = 1000; \ for (int i = 0; i < benchmark_iterations_; ++i) { \
for (int i = 0; i < runs; ++i) { \
FMT_A##To##FMT_PLANAR(src_argb, kStride, \ FMT_A##To##FMT_PLANAR(src_argb, kStride, \
dst_y_opt, kWidth, \ dst_y_opt, kWidth, \
dst_u_opt, kWidth / SUBSAMP_X, \ dst_u_opt, kWidth / SUBSAMP_X, \
...@@ -276,8 +273,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##N##_OptVsC) { \ ...@@ -276,8 +273,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##N##_OptVsC) { \
dst_argb_c, kWidth * BPP_B, \ dst_argb_c, kWidth * BPP_B, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
MaskCpuFlags(-1); \ MaskCpuFlags(-1); \
const int runs = 1000; \ for (int i = 0; i < benchmark_iterations_; ++i) { \
for (int i = 0; i < runs; ++i) { \
FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \ FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
dst_argb_opt, kWidth * BPP_B, \ dst_argb_opt, kWidth * BPP_B, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
...@@ -322,7 +318,7 @@ TESTATOB(M420, 3 / 2, 1, ARGB, 4) ...@@ -322,7 +318,7 @@ TESTATOB(M420, 3 / 2, 1, ARGB, 4)
#define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, FMT_B, BPP_B) \ #define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, FMT_B, BPP_B) \
TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \ TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \
srandom(time(NULL)); \ srandom(time(NULL)); \
for (int times = 0; times < 1000; ++times) { \ for (int times = 0; times < benchmark_iterations_; ++times) { \
const int kWidth = (random() & 63) + 1; \ const int kWidth = (random() & 63) + 1; \
const int kHeight = (random() & 31) + 1; \ const int kHeight = (random() & 31) + 1; \
align_buffer_page_end(src_argb, (kWidth * BPP_A) * kHeight); \ align_buffer_page_end(src_argb, (kWidth * BPP_A) * kHeight); \
...@@ -422,7 +418,7 @@ TEST_F(libyuvTest, TestAttenuate) { ...@@ -422,7 +418,7 @@ TEST_F(libyuvTest, TestAttenuate) {
} }
ARGBAttenuate(&orig_pixels[0][0], 0, &atten_pixels[0][0], 0, 256, 1); ARGBAttenuate(&orig_pixels[0][0], 0, &atten_pixels[0][0], 0, 256, 1);
ARGBUnattenuate(&atten_pixels[0][0], 0, &unatten_pixels[0][0], 0, 256, 1); ARGBUnattenuate(&atten_pixels[0][0], 0, &unatten_pixels[0][0], 0, 256, 1);
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBAttenuate(&unatten_pixels[0][0], 0, &atten2_pixels[0][0], 0, 256, 1); ARGBAttenuate(&unatten_pixels[0][0], 0, &atten2_pixels[0][0], 0, 256, 1);
} }
for (int i = 0; i < 256; ++i) { for (int i = 0; i < 256; ++i) {
...@@ -522,7 +518,7 @@ TEST_F(libyuvTest, TestARGBGray) { ...@@ -522,7 +518,7 @@ TEST_F(libyuvTest, TestARGBGray) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBGray(&orig_pixels[0][0], 0, 0, 0, 256, 1); ARGBGray(&orig_pixels[0][0], 0, 0, 0, 256, 1);
} }
} }
...@@ -577,7 +573,7 @@ TEST_F(libyuvTest, TestARGBGrayTo) { ...@@ -577,7 +573,7 @@ TEST_F(libyuvTest, TestARGBGrayTo) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBGrayTo(&orig_pixels[0][0], 0, &gray_pixels[0][0], 0, 256, 1); ARGBGrayTo(&orig_pixels[0][0], 0, &gray_pixels[0][0], 0, 256, 1);
} }
} }
...@@ -631,7 +627,7 @@ TEST_F(libyuvTest, TestARGBSepia) { ...@@ -631,7 +627,7 @@ TEST_F(libyuvTest, TestARGBSepia) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBSepia(&orig_pixels[0][0], 0, 0, 0, 256, 1); ARGBSepia(&orig_pixels[0][0], 0, 0, 0, 256, 1);
} }
} }
...@@ -692,7 +688,7 @@ TEST_F(libyuvTest, TestARGBColorMatrix) { ...@@ -692,7 +688,7 @@ TEST_F(libyuvTest, TestARGBColorMatrix) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBColorMatrix(&orig_pixels[0][0], 0, &kARGBToSepia[0], 0, 0, 256, 1); ARGBColorMatrix(&orig_pixels[0][0], 0, &kARGBToSepia[0], 0, 0, 256, 1);
} }
} }
...@@ -750,7 +746,7 @@ TEST_F(libyuvTest, TestARGBColorTable) { ...@@ -750,7 +746,7 @@ TEST_F(libyuvTest, TestARGBColorTable) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBColorTable(&orig_pixels[0][0], 0, &kARGBTable[0], 0, 0, 256, 1); ARGBColorTable(&orig_pixels[0][0], 0, &kARGBTable[0], 0, 0, 256, 1);
} }
} }
...@@ -773,7 +769,7 @@ TEST_F(libyuvTest, TestARGBQuantize) { ...@@ -773,7 +769,7 @@ TEST_F(libyuvTest, TestARGBQuantize) {
EXPECT_EQ(i / 3 / 8 * 8 + 8 / 2, orig_pixels[i][2]); EXPECT_EQ(i / 3 / 8 * 8 + 8 / 2, orig_pixels[i][2]);
EXPECT_EQ(i, orig_pixels[i][3]); EXPECT_EQ(i, orig_pixels[i][3]);
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBQuantize(&orig_pixels[0][0], 0, ARGBQuantize(&orig_pixels[0][0], 0,
(65536 + (8 / 2)) / 8, 8, 8 / 2, 0, 0, 256, 1); (65536 + (8 / 2)) / 8, 8, 8 / 2, 0, 0, 256, 1);
} }
...@@ -797,7 +793,7 @@ TEST_F(libyuvTest, TestARGBMirror) { ...@@ -797,7 +793,7 @@ TEST_F(libyuvTest, TestARGBMirror) {
EXPECT_EQ(i / 3, dst_pixels[255 - i][2]); EXPECT_EQ(i / 3, dst_pixels[255 - i][2]);
EXPECT_EQ(i / 4, dst_pixels[255 - i][3]); EXPECT_EQ(i / 4, dst_pixels[255 - i][3]);
} }
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBMirror(&orig_pixels[0][0], 0, &dst_pixels[0][0], 0, 256, 1); ARGBMirror(&orig_pixels[0][0], 0, &dst_pixels[0][0], 0, 256, 1);
} }
} }
...@@ -846,7 +842,7 @@ TEST_F(libyuvTest, TestShade) { ...@@ -846,7 +842,7 @@ TEST_F(libyuvTest, TestShade) {
EXPECT_EQ(20u, shade_pixels[0][2]); EXPECT_EQ(20u, shade_pixels[0][2]);
EXPECT_EQ(40u, shade_pixels[0][3]); EXPECT_EQ(40u, shade_pixels[0][3]);
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBShade(&orig_pixels[0][0], 0, &shade_pixels[0][0], 0, 256, 1, ARGBShade(&orig_pixels[0][0], 0, &shade_pixels[0][0], 0, 256, 1,
0x80808080); 0x80808080);
} }
...@@ -925,7 +921,7 @@ TEST_F(libyuvTest, TestInterpolate) { ...@@ -925,7 +921,7 @@ TEST_F(libyuvTest, TestInterpolate) {
EXPECT_EQ(16u, interpolate_pixels[0][2]); EXPECT_EQ(16u, interpolate_pixels[0][2]);
EXPECT_EQ(32u, interpolate_pixels[0][3]); EXPECT_EQ(32u, interpolate_pixels[0][3]);
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0,
&interpolate_pixels[0][0], 0, 256, 1, 128); &interpolate_pixels[0][0], 0, 256, 1, 128);
} }
...@@ -961,13 +957,13 @@ TEST_F(libyuvTest, TestAffine) { ...@@ -961,13 +957,13 @@ TEST_F(libyuvTest, TestAffine) {
#if defined(HAS_ARGBAFFINEROW_SSE2) #if defined(HAS_ARGBAFFINEROW_SSE2)
int has_sse2 = TestCpuFlag(kCpuHasSSE2); int has_sse2 = TestCpuFlag(kCpuHasSSE2);
if (has_sse2) { if (has_sse2) {
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBAffineRow_SSE2(&orig_pixels_0[0][0], 0, &interpolate_pixels_Opt[0][0], ARGBAffineRow_SSE2(&orig_pixels_0[0][0], 0, &interpolate_pixels_Opt[0][0],
uv_step, 256); uv_step, 256);
} }
} else { } else {
#endif #endif
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) { for (int i = 0; i < benchmark_iterations_ * 1280 * 720 / 256; ++i) {
ARGBAffineRow_C(&orig_pixels_0[0][0], 0, &interpolate_pixels_C[0][0], ARGBAffineRow_C(&orig_pixels_0[0][0], 0, &interpolate_pixels_C[0][0],
uv_step, 256); uv_step, 256);
} }
......
...@@ -19,7 +19,7 @@ namespace libyuv { ...@@ -19,7 +19,7 @@ namespace libyuv {
static int ARGBTestRotate(int src_width, int src_height, static int ARGBTestRotate(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode) { libyuv::RotationMode mode, const int runs) {
const int b = 128; const int b = 128;
int src_argb_plane_size = (src_width + b * 2) * (src_height + b * 2) * 4; int src_argb_plane_size = (src_width + b * 2) * (src_height + b * 2) * 4;
int src_stride_argb = (b * 2 + src_width) * 4; int src_stride_argb = (b * 2 + src_width) * 4;
...@@ -39,7 +39,6 @@ static int ARGBTestRotate(int src_width, int src_height, ...@@ -39,7 +39,6 @@ static int ARGBTestRotate(int src_width, int src_height,
} }
} }
const int runs = 1000;
align_buffer_16(dst_argb_c, dst_argb_plane_size) align_buffer_16(dst_argb_c, dst_argb_plane_size)
align_buffer_16(dst_argb_opt, dst_argb_plane_size) align_buffer_16(dst_argb_opt, dst_argb_plane_size)
memset(dst_argb_c, 2, dst_argb_plane_size); memset(dst_argb_c, 2, dst_argb_plane_size);
...@@ -104,7 +103,8 @@ TEST_F(libyuvTest, ARGBRotate0) { ...@@ -104,7 +103,8 @@ TEST_F(libyuvTest, ARGBRotate0) {
const int dst_height = 720; const int dst_height = 720;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate0); dst_width, dst_height, kRotate0,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -115,7 +115,8 @@ TEST_F(libyuvTest, ARGBRotate90) { ...@@ -115,7 +115,8 @@ TEST_F(libyuvTest, ARGBRotate90) {
const int dst_height = 1280; const int dst_height = 1280;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate90); dst_width, dst_height, kRotate90,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -126,7 +127,8 @@ TEST_F(libyuvTest, ARGBRotate180) { ...@@ -126,7 +127,8 @@ TEST_F(libyuvTest, ARGBRotate180) {
const int dst_height = 720; const int dst_height = 720;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate180); dst_width, dst_height, kRotate180,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -137,7 +139,8 @@ TEST_F(libyuvTest, ARGBRotate270) { ...@@ -137,7 +139,8 @@ TEST_F(libyuvTest, ARGBRotate270) {
const int dst_height = 1280; const int dst_height = 1280;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate270); dst_width, dst_height, kRotate270,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -148,7 +151,8 @@ TEST_F(libyuvTest, ARGBRotate0_Odd) { ...@@ -148,7 +151,8 @@ TEST_F(libyuvTest, ARGBRotate0_Odd) {
const int dst_height = 719; const int dst_height = 719;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate0); dst_width, dst_height, kRotate0,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -159,7 +163,8 @@ TEST_F(libyuvTest, ARGBRotate90_Odd) { ...@@ -159,7 +163,8 @@ TEST_F(libyuvTest, ARGBRotate90_Odd) {
const int dst_height = 1277; const int dst_height = 1277;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate90); dst_width, dst_height, kRotate90,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -170,7 +175,8 @@ TEST_F(libyuvTest, ARGBRotate180_Odd) { ...@@ -170,7 +175,8 @@ TEST_F(libyuvTest, ARGBRotate180_Odd) {
const int dst_height = 719; const int dst_height = 719;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate180); dst_width, dst_height, kRotate180,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
...@@ -181,7 +187,8 @@ TEST_F(libyuvTest, ARGBRotate270_Odd) { ...@@ -181,7 +187,8 @@ TEST_F(libyuvTest, ARGBRotate270_Odd) {
const int dst_height = 1277; const int dst_height = 1277;
int err = ARGBTestRotate(src_width, src_height, int err = ARGBTestRotate(src_width, src_height,
dst_width, dst_height, kRotate270); dst_width, dst_height, kRotate270,
benchmark_iterations_);
EXPECT_GE(1, err); EXPECT_GE(1, err);
} }
......
...@@ -19,7 +19,7 @@ namespace libyuv { ...@@ -19,7 +19,7 @@ namespace libyuv {
static int ARGBTestFilter(int src_width, int src_height, static int ARGBTestFilter(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
FilterMode f) { FilterMode f, const int benchmark_iterations_) {
const int b = 128; const int b = 128;
int src_argb_plane_size = (src_width + b * 2) * (src_height + b * 2) * 4; int src_argb_plane_size = (src_width + b * 2) * (src_height + b * 2) * 4;
int src_stride_argb = (b * 2 + src_width) * 4; int src_stride_argb = (b * 2 + src_width) * 4;
...@@ -39,7 +39,6 @@ static int ARGBTestFilter(int src_width, int src_height, ...@@ -39,7 +39,6 @@ static int ARGBTestFilter(int src_width, int src_height,
} }
} }
const int runs = 1000;
align_buffer_16(dst_argb_c, dst_argb_plane_size) align_buffer_16(dst_argb_c, dst_argb_plane_size)
align_buffer_16(dst_argb_opt, dst_argb_plane_size) align_buffer_16(dst_argb_opt, dst_argb_plane_size)
memset(dst_argb_c, 2, dst_argb_plane_size); memset(dst_argb_c, 2, dst_argb_plane_size);
...@@ -59,23 +58,23 @@ static int ARGBTestFilter(int src_width, int src_height, ...@@ -59,23 +58,23 @@ static int ARGBTestFilter(int src_width, int src_height,
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(0); // Disable all CPU optimization.
double c_time = get_time(); double c_time = get_time();
for (i = 0; i < runs; ++i) { for (i = 0; i < benchmark_iterations_; ++i) {
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb, ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
src_width, src_height, src_width, src_height,
dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb, dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
dst_width, dst_height, f); dst_width, dst_height, f);
} }
c_time = (get_time() - c_time) / runs; c_time = (get_time() - c_time) / benchmark_iterations_;
MaskCpuFlags(-1); // Enable all CPU optimization. MaskCpuFlags(-1); // Enable all CPU optimization.
double opt_time = get_time(); double opt_time = get_time();
for (i = 0; i < runs; ++i) { for (i = 0; i < benchmark_iterations_; ++i) {
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb, ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
src_width, src_height, src_width, src_height,
dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb, dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
dst_width, dst_height, f); dst_width, dst_height, f);
} }
opt_time = (get_time() - opt_time) / runs; opt_time = (get_time() - opt_time) / benchmark_iterations_;
// Report performance of C vs OPT // Report performance of C vs OPT
printf("filter %d - %8d us C - %8d us OPT\n", printf("filter %d - %8d us C - %8d us OPT\n",
...@@ -111,7 +110,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy2) { ...@@ -111,7 +110,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy2) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -125,7 +125,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy4) { ...@@ -125,7 +125,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy4) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -139,7 +140,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy5) { ...@@ -139,7 +140,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy5) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -153,7 +155,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy8) { ...@@ -153,7 +155,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy8) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -167,7 +170,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy16) { ...@@ -167,7 +170,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy16) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -181,7 +185,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy34) { ...@@ -181,7 +185,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy34) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -195,7 +200,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy38) { ...@@ -195,7 +200,8 @@ TEST_F(libyuvTest, ARGBScaleDownBy38) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -209,7 +215,8 @@ TEST_F(libyuvTest, ARGBScaleTo1366) { ...@@ -209,7 +215,8 @@ TEST_F(libyuvTest, ARGBScaleTo1366) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -223,7 +230,8 @@ TEST_F(libyuvTest, ARGBScaleTo4074) { ...@@ -223,7 +230,8 @@ TEST_F(libyuvTest, ARGBScaleTo4074) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -238,7 +246,8 @@ TEST_F(libyuvTest, ARGBScaleTo853) { ...@@ -238,7 +246,8 @@ TEST_F(libyuvTest, ARGBScaleTo853) {
for (int f = 0; f < 2; ++f) { for (int f = 0; f < 2; ++f) {
int max_diff = ARGBTestFilter(src_width, src_height, int max_diff = ARGBTestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f)); static_cast<FilterMode>(f),
benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
......
...@@ -19,7 +19,7 @@ namespace libyuv { ...@@ -19,7 +19,7 @@ namespace libyuv {
static int TestFilter(int src_width, int src_height, static int TestFilter(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
FilterMode f, int rounding) { FilterMode f, int rounding, const int benchmark_iterations_) {
const int b = 128 * rounding; const int b = 128 * rounding;
int src_width_uv = (src_width + rounding) >> 1; int src_width_uv = (src_width + rounding) >> 1;
int src_height_uv = (src_height + rounding) >> 1; int src_height_uv = (src_height + rounding) >> 1;
...@@ -59,7 +59,6 @@ static int TestFilter(int src_width, int src_height, ...@@ -59,7 +59,6 @@ static int TestFilter(int src_width, int src_height,
} }
} }
const int runs = 1000;
align_buffer_page_end(dst_y_c, dst_y_plane_size) align_buffer_page_end(dst_y_c, dst_y_plane_size)
align_buffer_page_end(dst_u_c, dst_uv_plane_size) align_buffer_page_end(dst_u_c, dst_uv_plane_size)
align_buffer_page_end(dst_v_c, dst_uv_plane_size) align_buffer_page_end(dst_v_c, dst_uv_plane_size)
...@@ -89,7 +88,7 @@ static int TestFilter(int src_width, int src_height, ...@@ -89,7 +88,7 @@ static int TestFilter(int src_width, int src_height,
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(0); // Disable all CPU optimization.
double c_time = get_time(); double c_time = get_time();
for (i = 0; i < runs; ++i) { for (i = 0; i < benchmark_iterations_; ++i) {
I420Scale(src_y + (src_stride_y * b) + b, src_stride_y, I420Scale(src_y + (src_stride_y * b) + b, src_stride_y,
src_u + (src_stride_uv * b) + b, src_stride_uv, src_u + (src_stride_uv * b) + b, src_stride_uv,
src_v + (src_stride_uv * b) + b, src_stride_uv, src_v + (src_stride_uv * b) + b, src_stride_uv,
...@@ -99,11 +98,11 @@ static int TestFilter(int src_width, int src_height, ...@@ -99,11 +98,11 @@ static int TestFilter(int src_width, int src_height,
dst_v_c + (dst_stride_uv * b) + b, dst_stride_uv, dst_v_c + (dst_stride_uv * b) + b, dst_stride_uv,
dst_width, dst_height, f); dst_width, dst_height, f);
} }
c_time = (get_time() - c_time) / runs; c_time = (get_time() - c_time) / benchmark_iterations_;
MaskCpuFlags(-1); // Enable all CPU optimization. MaskCpuFlags(-1); // Enable all CPU optimization.
double opt_time = get_time(); double opt_time = get_time();
for (i = 0; i < runs; ++i) { for (i = 0; i < benchmark_iterations_; ++i) {
I420Scale(src_y + (src_stride_y * b) + b, src_stride_y, I420Scale(src_y + (src_stride_y * b) + b, src_stride_y,
src_u + (src_stride_uv * b) + b, src_stride_uv, src_u + (src_stride_uv * b) + b, src_stride_uv,
src_v + (src_stride_uv * b) + b, src_stride_uv, src_v + (src_stride_uv * b) + b, src_stride_uv,
...@@ -113,7 +112,7 @@ static int TestFilter(int src_width, int src_height, ...@@ -113,7 +112,7 @@ static int TestFilter(int src_width, int src_height,
dst_v_opt + (dst_stride_uv * b) + b, dst_stride_uv, dst_v_opt + (dst_stride_uv * b) + b, dst_stride_uv,
dst_width, dst_height, f); dst_width, dst_height, f);
} }
opt_time = (get_time() - opt_time) / runs; opt_time = (get_time() - opt_time) / benchmark_iterations_;
// Report performance of C vs OPT // Report performance of C vs OPT
printf("filter %d - %8d us C - %8d us OPT\n", printf("filter %d - %8d us C - %8d us OPT\n",
...@@ -172,7 +171,7 @@ TEST_F(libyuvTest, ScaleDownBy2) { ...@@ -172,7 +171,7 @@ TEST_F(libyuvTest, ScaleDownBy2) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -186,7 +185,7 @@ TEST_F(libyuvTest, ScaleDownBy4) { ...@@ -186,7 +185,7 @@ TEST_F(libyuvTest, ScaleDownBy4) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 2);; // This is the only scale factor with error of 2. EXPECT_LE(max_diff, 2);; // This is the only scale factor with error of 2.
} }
} }
...@@ -200,7 +199,7 @@ TEST_F(libyuvTest, ScaleDownBy5) { ...@@ -200,7 +199,7 @@ TEST_F(libyuvTest, ScaleDownBy5) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -214,7 +213,7 @@ TEST_F(libyuvTest, ScaleDownBy8) { ...@@ -214,7 +213,7 @@ TEST_F(libyuvTest, ScaleDownBy8) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -228,7 +227,7 @@ TEST_F(libyuvTest, ScaleDownBy16) { ...@@ -228,7 +227,7 @@ TEST_F(libyuvTest, ScaleDownBy16) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -242,7 +241,7 @@ TEST_F(libyuvTest, ScaleDownBy34) { ...@@ -242,7 +241,7 @@ TEST_F(libyuvTest, ScaleDownBy34) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -256,7 +255,7 @@ TEST_F(libyuvTest, ScaleDownBy38) { ...@@ -256,7 +255,7 @@ TEST_F(libyuvTest, ScaleDownBy38) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -270,7 +269,7 @@ TEST_F(libyuvTest, ScaleTo1366) { ...@@ -270,7 +269,7 @@ TEST_F(libyuvTest, ScaleTo1366) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -284,7 +283,7 @@ TEST_F(libyuvTest, ScaleTo4074) { ...@@ -284,7 +283,7 @@ TEST_F(libyuvTest, ScaleTo4074) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -298,7 +297,7 @@ TEST_F(libyuvTest, ScaleTo853) { ...@@ -298,7 +297,7 @@ TEST_F(libyuvTest, ScaleTo853) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -312,7 +311,7 @@ TEST_F(libyuvTest, ScaleTo853Wrong) { ...@@ -312,7 +311,7 @@ TEST_F(libyuvTest, ScaleTo853Wrong) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 0); static_cast<FilterMode>(f), 0, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -327,7 +326,7 @@ TEST_F(libyuvTest, ScaleTo684) { ...@@ -327,7 +326,7 @@ TEST_F(libyuvTest, ScaleTo684) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -341,7 +340,7 @@ TEST_F(libyuvTest, ScaleTo342) { ...@@ -341,7 +340,7 @@ TEST_F(libyuvTest, ScaleTo342) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
...@@ -355,7 +354,7 @@ TEST_F(libyuvTest, ScaleToHalf342) { ...@@ -355,7 +354,7 @@ TEST_F(libyuvTest, ScaleToHalf342) {
for (int f = 0; f < 3; ++f) { for (int f = 0; f < 3; ++f) {
int max_diff = TestFilter(src_width, src_height, int max_diff = TestFilter(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
static_cast<FilterMode>(f), 1); static_cast<FilterMode>(f), 1, benchmark_iterations_);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
} }
......
...@@ -12,8 +12,12 @@ ...@@ -12,8 +12,12 @@
#include <cstring> #include <cstring>
// Change this to 1000 for benchmarking.
// TODO(fbarchard): Add command line parsing to pass this as option.
#define BENCHMARK_ITERATIONS 1
libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
benchmark_iterations_(1000), benchmark_width_(1280), benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(1280),
benchmark_height_(720) { benchmark_height_(720) {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment