OLD | NEW |
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 LibYUVConvertTest::LibYUVConvertTest() : rotate_max_w_(128), rotate_max_h_(128), | 23 LibYUVConvertTest::LibYUVConvertTest() : |
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) { | 27 if (repeat) { |
28 benchmark_iterations_ = atoi(repeat); // NOLINT | 28 benchmark_iterations_ = atoi(repeat); // NOLINT |
29 // For quicker unittests, default is 128 x 72. But when benchmarking, | 29 // For quicker unittests, default is 128 x 72. But when benchmarking, |
30 // default to 720p. Allow size to specify. | 30 // default to 720p. Allow size to specify. |
31 if (benchmark_iterations_ > 1) { | 31 if (benchmark_iterations_ > 1) { |
32 benchmark_width_ = 1280; | 32 benchmark_width_ = 1280; |
33 benchmark_height_ = 720; | 33 benchmark_height_ = 720; |
(...skipping 14 matching lines...) Expand all Loading... |
48 benchmark_pixels_div256_ = static_cast<int>(( | 48 benchmark_pixels_div256_ = static_cast<int>(( |
49 static_cast<double>(Abs(benchmark_width_)) * | 49 static_cast<double>(Abs(benchmark_width_)) * |
50 static_cast<double>(Abs(benchmark_height_)) * | 50 static_cast<double>(Abs(benchmark_height_)) * |
51 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); | 51 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); |
52 benchmark_pixels_div1280_ = static_cast<int>(( | 52 benchmark_pixels_div1280_ = static_cast<int>(( |
53 static_cast<double>(Abs(benchmark_width_)) * | 53 static_cast<double>(Abs(benchmark_width_)) * |
54 static_cast<double>(Abs(benchmark_height_)) * | 54 static_cast<double>(Abs(benchmark_height_)) * |
55 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); | 55 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
56 } | 56 } |
57 | 57 |
58 LibYUVScaleTest::LibYUVScaleTest() : rotate_max_w_(128), rotate_max_h_(128), | 58 LibYUVColorTest::LibYUVColorTest() : |
59 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), | 59 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), |
60 benchmark_height_(72), disable_cpu_flags_(0) { | 60 benchmark_height_(72), disable_cpu_flags_(0) { |
61 const char* repeat = getenv("LIBYUV_REPEAT"); | 61 const char* repeat = getenv("LIBYUV_REPEAT"); |
62 if (repeat) { | 62 if (repeat) { |
63 benchmark_iterations_ = atoi(repeat); // NOLINT | 63 benchmark_iterations_ = atoi(repeat); // NOLINT |
64 // For quicker unittests, default is 128 x 72. But when benchmarking, | 64 // For quicker unittests, default is 128 x 72. But when benchmarking, |
65 // default to 720p. Allow size to specify. | 65 // default to 720p. Allow size to specify. |
66 if (benchmark_iterations_ > 1) { | 66 if (benchmark_iterations_ > 1) { |
67 benchmark_width_ = 1280; | 67 benchmark_width_ = 1280; |
68 benchmark_height_ = 720; | 68 benchmark_height_ = 720; |
(...skipping 14 matching lines...) Expand all Loading... |
83 benchmark_pixels_div256_ = static_cast<int>(( | 83 benchmark_pixels_div256_ = static_cast<int>(( |
84 static_cast<double>(Abs(benchmark_width_)) * | 84 static_cast<double>(Abs(benchmark_width_)) * |
85 static_cast<double>(Abs(benchmark_height_)) * | 85 static_cast<double>(Abs(benchmark_height_)) * |
86 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); | 86 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); |
87 benchmark_pixels_div1280_ = static_cast<int>(( | 87 benchmark_pixels_div1280_ = static_cast<int>(( |
88 static_cast<double>(Abs(benchmark_width_)) * | 88 static_cast<double>(Abs(benchmark_width_)) * |
89 static_cast<double>(Abs(benchmark_height_)) * | 89 static_cast<double>(Abs(benchmark_height_)) * |
90 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); | 90 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
91 } | 91 } |
92 | 92 |
93 LibYUVRotateTest::LibYUVRotateTest() : rotate_max_w_(128), rotate_max_h_(128), | 93 LibYUVScaleTest::LibYUVScaleTest() : |
94 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), | 94 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), |
95 benchmark_height_(72), disable_cpu_flags_(0) { | 95 benchmark_height_(72), disable_cpu_flags_(0) { |
96 const char* repeat = getenv("LIBYUV_REPEAT"); | 96 const char* repeat = getenv("LIBYUV_REPEAT"); |
97 if (repeat) { | 97 if (repeat) { |
98 benchmark_iterations_ = atoi(repeat); // NOLINT | 98 benchmark_iterations_ = atoi(repeat); // NOLINT |
99 // For quicker unittests, default is 128 x 72. But when benchmarking, | 99 // For quicker unittests, default is 128 x 72. But when benchmarking, |
100 // default to 720p. Allow size to specify. | 100 // default to 720p. Allow size to specify. |
101 if (benchmark_iterations_ > 1) { | 101 if (benchmark_iterations_ > 1) { |
102 benchmark_width_ = 1280; | 102 benchmark_width_ = 1280; |
103 benchmark_height_ = 720; | 103 benchmark_height_ = 720; |
(...skipping 14 matching lines...) Expand all Loading... |
118 benchmark_pixels_div256_ = static_cast<int>(( | 118 benchmark_pixels_div256_ = static_cast<int>(( |
119 static_cast<double>(Abs(benchmark_width_)) * | 119 static_cast<double>(Abs(benchmark_width_)) * |
120 static_cast<double>(Abs(benchmark_height_)) * | 120 static_cast<double>(Abs(benchmark_height_)) * |
121 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); | 121 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); |
122 benchmark_pixels_div1280_ = static_cast<int>(( | 122 benchmark_pixels_div1280_ = static_cast<int>(( |
123 static_cast<double>(Abs(benchmark_width_)) * | 123 static_cast<double>(Abs(benchmark_width_)) * |
124 static_cast<double>(Abs(benchmark_height_)) * | 124 static_cast<double>(Abs(benchmark_height_)) * |
125 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); | 125 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
126 } | 126 } |
127 | 127 |
128 LibYUVPlanarTest::LibYUVPlanarTest() : rotate_max_w_(128), rotate_max_h_(128), | 128 LibYUVRotateTest::LibYUVRotateTest() : |
129 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), | 129 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), |
130 benchmark_height_(72), disable_cpu_flags_(0) { | 130 benchmark_height_(72), disable_cpu_flags_(0) { |
131 const char* repeat = getenv("LIBYUV_REPEAT"); | 131 const char* repeat = getenv("LIBYUV_REPEAT"); |
132 if (repeat) { | 132 if (repeat) { |
133 benchmark_iterations_ = atoi(repeat); // NOLINT | 133 benchmark_iterations_ = atoi(repeat); // NOLINT |
134 // For quicker unittests, default is 128 x 72. But when benchmarking, | 134 // For quicker unittests, default is 128 x 72. But when benchmarking, |
135 // default to 720p. Allow size to specify. | 135 // default to 720p. Allow size to specify. |
136 if (benchmark_iterations_ > 1) { | 136 if (benchmark_iterations_ > 1) { |
137 benchmark_width_ = 1280; | 137 benchmark_width_ = 1280; |
138 benchmark_height_ = 720; | 138 benchmark_height_ = 720; |
(...skipping 14 matching lines...) Expand all Loading... |
153 benchmark_pixels_div256_ = static_cast<int>(( | 153 benchmark_pixels_div256_ = static_cast<int>(( |
154 static_cast<double>(Abs(benchmark_width_)) * | 154 static_cast<double>(Abs(benchmark_width_)) * |
155 static_cast<double>(Abs(benchmark_height_)) * | 155 static_cast<double>(Abs(benchmark_height_)) * |
156 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); | 156 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); |
157 benchmark_pixels_div1280_ = static_cast<int>(( | 157 benchmark_pixels_div1280_ = static_cast<int>(( |
158 static_cast<double>(Abs(benchmark_width_)) * | 158 static_cast<double>(Abs(benchmark_width_)) * |
159 static_cast<double>(Abs(benchmark_height_)) * | 159 static_cast<double>(Abs(benchmark_height_)) * |
160 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); | 160 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
161 } | 161 } |
162 | 162 |
163 LibYUVBaseTest::LibYUVBaseTest() : rotate_max_w_(128), rotate_max_h_(128), | 163 LibYUVPlanarTest::LibYUVPlanarTest() : |
164 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), | 164 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), |
165 benchmark_height_(72), disable_cpu_flags_(0) { | 165 benchmark_height_(72), disable_cpu_flags_(0) { |
166 const char* repeat = getenv("LIBYUV_REPEAT"); | 166 const char* repeat = getenv("LIBYUV_REPEAT"); |
| 167 if (repeat) { |
| 168 benchmark_iterations_ = atoi(repeat); // NOLINT |
| 169 // For quicker unittests, default is 128 x 72. But when benchmarking, |
| 170 // default to 720p. Allow size to specify. |
| 171 if (benchmark_iterations_ > 1) { |
| 172 benchmark_width_ = 1280; |
| 173 benchmark_height_ = 720; |
| 174 } |
| 175 } |
| 176 const char* width = getenv("LIBYUV_WIDTH"); |
| 177 if (width) { |
| 178 benchmark_width_ = atoi(width); // NOLINT |
| 179 } |
| 180 const char* height = getenv("LIBYUV_HEIGHT"); |
| 181 if (height) { |
| 182 benchmark_height_ = atoi(height); // NOLINT |
| 183 } |
| 184 const char* cpu_flags = getenv("LIBYUV_FLAGS"); |
| 185 if (cpu_flags) { |
| 186 disable_cpu_flags_ = atoi(cpu_flags); // NOLINT |
| 187 } |
| 188 benchmark_pixels_div256_ = static_cast<int>(( |
| 189 static_cast<double>(Abs(benchmark_width_)) * |
| 190 static_cast<double>(Abs(benchmark_height_)) * |
| 191 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); |
| 192 benchmark_pixels_div1280_ = static_cast<int>(( |
| 193 static_cast<double>(Abs(benchmark_width_)) * |
| 194 static_cast<double>(Abs(benchmark_height_)) * |
| 195 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
| 196 } |
| 197 |
| 198 LibYUVBaseTest::LibYUVBaseTest() : |
| 199 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), |
| 200 benchmark_height_(72), disable_cpu_flags_(0) { |
| 201 const char* repeat = getenv("LIBYUV_REPEAT"); |
167 if (repeat) { | 202 if (repeat) { |
168 benchmark_iterations_ = atoi(repeat); // NOLINT | 203 benchmark_iterations_ = atoi(repeat); // NOLINT |
169 // For quicker unittests, default is 128 x 72. But when benchmarking, | 204 // For quicker unittests, default is 128 x 72. But when benchmarking, |
170 // default to 720p. Allow size to specify. | 205 // default to 720p. Allow size to specify. |
171 if (benchmark_iterations_ > 1) { | 206 if (benchmark_iterations_ > 1) { |
172 benchmark_width_ = 1280; | 207 benchmark_width_ = 1280; |
173 benchmark_height_ = 720; | 208 benchmark_height_ = 720; |
174 } | 209 } |
175 } | 210 } |
176 const char* width = getenv("LIBYUV_WIDTH"); | 211 const char* width = getenv("LIBYUV_WIDTH"); |
(...skipping 15 matching lines...) Expand all Loading... |
192 benchmark_pixels_div1280_ = static_cast<int>(( | 227 benchmark_pixels_div1280_ = static_cast<int>(( |
193 static_cast<double>(Abs(benchmark_width_)) * | 228 static_cast<double>(Abs(benchmark_width_)) * |
194 static_cast<double>(Abs(benchmark_height_)) * | 229 static_cast<double>(Abs(benchmark_height_)) * |
195 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); | 230 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); |
196 } | 231 } |
197 | 232 |
198 int main(int argc, char** argv) { | 233 int main(int argc, char** argv) { |
199 ::testing::InitGoogleTest(&argc, argv); | 234 ::testing::InitGoogleTest(&argc, argv); |
200 return RUN_ALL_TESTS(); | 235 return RUN_ALL_TESTS(); |
201 } | 236 } |
OLD | NEW |