Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: unit_test/unit_test.cc

Issue 1399523004: break up unittests into categories (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: bump version Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « unit_test/unit_test.h ('k') | unit_test/version_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "../unit_test/unit_test.h" 11 #include "../unit_test/unit_test.h"
12 12
13 #include <stdlib.h> // For getenv() 13 #include <stdlib.h> // For getenv()
14 14
15 #include <cstring> 15 #include <cstring>
16 16
17 // Change this to 1000 for benchmarking. 17 // Change this to 1000 for benchmarking.
18 // TODO(fbarchard): Add command line parsing to pass this as option. 18 // TODO(fbarchard): Add command line parsing to pass this as option.
19 #define BENCHMARK_ITERATIONS 1 19 #define BENCHMARK_ITERATIONS 1
20 20
21 int fastrand_seed = 0xfb; 21 int fastrand_seed = 0xfb;
22 22
23 libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), 23 LibYUVConvertTest::LibYUVConvertTest() : rotate_max_w_(128), rotate_max_h_(128),
24 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), 24 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
25 benchmark_height_(72), disable_cpu_flags_(0) { 25 benchmark_height_(72), disable_cpu_flags_(0) {
26 const char* repeat = getenv("LIBYUV_REPEAT"); 26 const char* repeat = getenv("LIBYUV_REPEAT");
27 if (repeat) {
28 benchmark_iterations_ = atoi(repeat); // NOLINT
29 // For quicker unittests, default is 128 x 72. But when benchmarking,
30 // default to 720p. Allow size to specify.
31 if (benchmark_iterations_ > 1) {
32 benchmark_width_ = 1280;
33 benchmark_height_ = 720;
34 }
35 }
36 const char* width = getenv("LIBYUV_WIDTH");
37 if (width) {
38 benchmark_width_ = atoi(width); // NOLINT
39 }
40 const char* height = getenv("LIBYUV_HEIGHT");
41 if (height) {
42 benchmark_height_ = atoi(height); // NOLINT
43 }
44 const char* cpu_flags = getenv("LIBYUV_FLAGS");
45 if (cpu_flags) {
46 disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
47 }
48 benchmark_pixels_div256_ = static_cast<int>((
49 static_cast<double>(Abs(benchmark_width_)) *
50 static_cast<double>(Abs(benchmark_height_)) *
51 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0);
52 benchmark_pixels_div1280_ = static_cast<int>((
53 static_cast<double>(Abs(benchmark_width_)) *
54 static_cast<double>(Abs(benchmark_height_)) *
55 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
56 }
57
58 LibYUVScaleTest::LibYUVScaleTest() : rotate_max_w_(128), rotate_max_h_(128),
59 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
60 benchmark_height_(72), disable_cpu_flags_(0) {
61 const char* repeat = getenv("LIBYUV_REPEAT");
62 if (repeat) {
63 benchmark_iterations_ = atoi(repeat); // NOLINT
64 // For quicker unittests, default is 128 x 72. But when benchmarking,
65 // default to 720p. Allow size to specify.
66 if (benchmark_iterations_ > 1) {
67 benchmark_width_ = 1280;
68 benchmark_height_ = 720;
69 }
70 }
71 const char* width = getenv("LIBYUV_WIDTH");
72 if (width) {
73 benchmark_width_ = atoi(width); // NOLINT
74 }
75 const char* height = getenv("LIBYUV_HEIGHT");
76 if (height) {
77 benchmark_height_ = atoi(height); // NOLINT
78 }
79 const char* cpu_flags = getenv("LIBYUV_FLAGS");
80 if (cpu_flags) {
81 disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
82 }
83 benchmark_pixels_div256_ = static_cast<int>((
84 static_cast<double>(Abs(benchmark_width_)) *
85 static_cast<double>(Abs(benchmark_height_)) *
86 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0);
87 benchmark_pixels_div1280_ = static_cast<int>((
88 static_cast<double>(Abs(benchmark_width_)) *
89 static_cast<double>(Abs(benchmark_height_)) *
90 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
91 }
92
93 LibYUVRotateTest::LibYUVRotateTest() : rotate_max_w_(128), rotate_max_h_(128),
94 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
95 benchmark_height_(72), disable_cpu_flags_(0) {
96 const char* repeat = getenv("LIBYUV_REPEAT");
97 if (repeat) {
98 benchmark_iterations_ = atoi(repeat); // NOLINT
99 // For quicker unittests, default is 128 x 72. But when benchmarking,
100 // default to 720p. Allow size to specify.
101 if (benchmark_iterations_ > 1) {
102 benchmark_width_ = 1280;
103 benchmark_height_ = 720;
104 }
105 }
106 const char* width = getenv("LIBYUV_WIDTH");
107 if (width) {
108 benchmark_width_ = atoi(width); // NOLINT
109 }
110 const char* height = getenv("LIBYUV_HEIGHT");
111 if (height) {
112 benchmark_height_ = atoi(height); // NOLINT
113 }
114 const char* cpu_flags = getenv("LIBYUV_FLAGS");
115 if (cpu_flags) {
116 disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
117 }
118 benchmark_pixels_div256_ = static_cast<int>((
119 static_cast<double>(Abs(benchmark_width_)) *
120 static_cast<double>(Abs(benchmark_height_)) *
121 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0);
122 benchmark_pixels_div1280_ = static_cast<int>((
123 static_cast<double>(Abs(benchmark_width_)) *
124 static_cast<double>(Abs(benchmark_height_)) *
125 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
126 }
127
128 LibYUVPlanarTest::LibYUVPlanarTest() : rotate_max_w_(128), rotate_max_h_(128),
129 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
130 benchmark_height_(72), disable_cpu_flags_(0) {
131 const char* repeat = getenv("LIBYUV_REPEAT");
132 if (repeat) {
133 benchmark_iterations_ = atoi(repeat); // NOLINT
134 // For quicker unittests, default is 128 x 72. But when benchmarking,
135 // default to 720p. Allow size to specify.
136 if (benchmark_iterations_ > 1) {
137 benchmark_width_ = 1280;
138 benchmark_height_ = 720;
139 }
140 }
141 const char* width = getenv("LIBYUV_WIDTH");
142 if (width) {
143 benchmark_width_ = atoi(width); // NOLINT
144 }
145 const char* height = getenv("LIBYUV_HEIGHT");
146 if (height) {
147 benchmark_height_ = atoi(height); // NOLINT
148 }
149 const char* cpu_flags = getenv("LIBYUV_FLAGS");
150 if (cpu_flags) {
151 disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
152 }
153 benchmark_pixels_div256_ = static_cast<int>((
154 static_cast<double>(Abs(benchmark_width_)) *
155 static_cast<double>(Abs(benchmark_height_)) *
156 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0);
157 benchmark_pixels_div1280_ = static_cast<int>((
158 static_cast<double>(Abs(benchmark_width_)) *
159 static_cast<double>(Abs(benchmark_height_)) *
160 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
161 }
162
163 LibYUVBaseTest::LibYUVBaseTest() : rotate_max_w_(128), rotate_max_h_(128),
164 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
165 benchmark_height_(72), disable_cpu_flags_(0) {
166 const char* repeat = getenv("LIBYUV_REPEAT");
27 if (repeat) { 167 if (repeat) {
28 benchmark_iterations_ = atoi(repeat); // NOLINT 168 benchmark_iterations_ = atoi(repeat); // NOLINT
29 // For quicker unittests, default is 128 x 72. But when benchmarking, 169 // For quicker unittests, default is 128 x 72. But when benchmarking,
30 // default to 720p. Allow size to specify. 170 // default to 720p. Allow size to specify.
31 if (benchmark_iterations_ > 1) { 171 if (benchmark_iterations_ > 1) {
32 benchmark_width_ = 1280; 172 benchmark_width_ = 1280;
33 benchmark_height_ = 720; 173 benchmark_height_ = 720;
34 } 174 }
35 } 175 }
36 const char* width = getenv("LIBYUV_WIDTH"); 176 const char* width = getenv("LIBYUV_WIDTH");
(...skipping 15 matching lines...) Expand all
52 benchmark_pixels_div1280_ = static_cast<int>(( 192 benchmark_pixels_div1280_ = static_cast<int>((
53 static_cast<double>(Abs(benchmark_width_)) * 193 static_cast<double>(Abs(benchmark_width_)) *
54 static_cast<double>(Abs(benchmark_height_)) * 194 static_cast<double>(Abs(benchmark_height_)) *
55 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); 195 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
56 } 196 }
57 197
58 int main(int argc, char** argv) { 198 int main(int argc, char** argv) {
59 ::testing::InitGoogleTest(&argc, argv); 199 ::testing::InitGoogleTest(&argc, argv);
60 return RUN_ALL_TESTS(); 200 return RUN_ALL_TESTS();
61 } 201 }
OLDNEW
« no previous file with comments | « unit_test/unit_test.h ('k') | unit_test/version_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698