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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 free(var##_mem); \ | 39 free(var##_mem); \ |
40 var = 0; | 40 var = 0; |
41 | 41 |
42 #ifdef WIN32 | 42 #ifdef WIN32 |
43 static inline double get_time() { | 43 static inline double get_time() { |
44 LARGE_INTEGER t, f; | 44 LARGE_INTEGER t, f; |
45 QueryPerformanceCounter(&t); | 45 QueryPerformanceCounter(&t); |
46 QueryPerformanceFrequency(&f); | 46 QueryPerformanceFrequency(&f); |
47 return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart); | 47 return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart); |
48 } | 48 } |
49 | |
50 #define random rand | |
51 #define srandom srand | |
52 #else | 49 #else |
53 static inline double get_time() { | 50 static inline double get_time() { |
54 struct timeval t; | 51 struct timeval t; |
55 struct timezone tzp; | 52 struct timezone tzp; |
56 gettimeofday(&t, &tzp); | 53 gettimeofday(&t, &tzp); |
57 return t.tv_sec + t.tv_usec * 1e-6; | 54 return t.tv_sec + t.tv_usec * 1e-6; |
58 } | 55 } |
59 #endif | 56 #endif |
60 | 57 |
| 58 extern int fastrand_seed; |
| 59 inline int fastrand() { |
| 60 fastrand_seed = fastrand_seed * 214013 + 2531011; |
| 61 return (fastrand_seed >> 16) & 0xffff; |
| 62 } |
| 63 |
61 static inline void MemRandomize(uint8* dst, int64 len) { | 64 static inline void MemRandomize(uint8* dst, int64 len) { |
62 int64 i; | 65 int64 i; |
63 for (i = 0; i < len - 1; i += 2) { | 66 for (i = 0; i < len - 1; i += 2) { |
64 *reinterpret_cast<uint16*>(dst) = random(); | 67 *reinterpret_cast<uint16*>(dst) = fastrand(); |
65 dst += 2; | 68 dst += 2; |
66 } | 69 } |
67 for (; i < len; ++i) { | 70 for (; i < len; ++i) { |
68 *dst++ = random(); | 71 *dst++ = fastrand(); |
69 } | 72 } |
70 } | 73 } |
71 | 74 |
72 class libyuvTest : public ::testing::Test { | 75 class libyuvTest : public ::testing::Test { |
73 protected: | 76 protected: |
74 libyuvTest(); | 77 libyuvTest(); |
75 | 78 |
76 const int rotate_max_w_; | 79 const int rotate_max_w_; |
77 const int rotate_max_h_; | 80 const int rotate_max_h_; |
78 | 81 |
79 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. | 82 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. |
80 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. | 83 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. |
81 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. | 84 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. |
82 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. | 85 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. |
83 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. | 86 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. |
84 int disable_cpu_flags_; // Default 0. Use -1 for benchmarking. | 87 int disable_cpu_flags_; // Default 0. Use -1 for benchmarking. |
85 }; | 88 }; |
86 | 89 |
87 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT | 90 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT |
OLD | NEW |