| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/cpu.h" | 6 #include "base/cpu.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Surface sizes for various test files. | 31 // Surface sizes for various test files. |
| 32 static const int kYUV12Size = kSourceYSize * 12 / 8; | 32 static const int kYUV12Size = kSourceYSize * 12 / 8; |
| 33 static const int kRGBSize = kSourceYSize * kBpp; | 33 static const int kRGBSize = kSourceYSize * kBpp; |
| 34 | 34 |
| 35 static const int kPerfTestIterations = 2000; | 35 static const int kPerfTestIterations = 2000; |
| 36 | 36 |
| 37 class YUVConvertPerfTest : public testing::Test { | 37 class YUVConvertPerfTest : public testing::Test { |
| 38 public: | 38 public: |
| 39 YUVConvertPerfTest() | 39 YUVConvertPerfTest() |
| 40 : yuv_bytes_(new uint8[kYUV12Size]), | 40 : yuv_bytes_(new uint8_t[kYUV12Size]), |
| 41 rgb_bytes_converted_(new uint8[kRGBSize]) { | 41 rgb_bytes_converted_(new uint8_t[kRGBSize]) { |
| 42 base::FilePath path; | 42 base::FilePath path; |
| 43 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &path)); | 43 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &path)); |
| 44 path = path.Append(FILE_PATH_LITERAL("media")) | 44 path = path.Append(FILE_PATH_LITERAL("media")) |
| 45 .Append(FILE_PATH_LITERAL("test")) | 45 .Append(FILE_PATH_LITERAL("test")) |
| 46 .Append(FILE_PATH_LITERAL("data")) | 46 .Append(FILE_PATH_LITERAL("data")) |
| 47 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); | 47 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); |
| 48 | 48 |
| 49 // Verify file size is correct. | 49 // Verify file size is correct. |
| 50 int64 actual_size = 0; | 50 int64_t actual_size = 0; |
| 51 base::GetFileSize(path, &actual_size); | 51 base::GetFileSize(path, &actual_size); |
| 52 CHECK_EQ(actual_size, kYUV12Size); | 52 CHECK_EQ(actual_size, kYUV12Size); |
| 53 | 53 |
| 54 // Verify bytes read are correct. | 54 // Verify bytes read are correct. |
| 55 int bytes_read = base::ReadFile( | 55 int bytes_read = base::ReadFile( |
| 56 path, reinterpret_cast<char*>(yuv_bytes_.get()), kYUV12Size); | 56 path, reinterpret_cast<char*>(yuv_bytes_.get()), kYUV12Size); |
| 57 | 57 |
| 58 CHECK_EQ(bytes_read, kYUV12Size); | 58 CHECK_EQ(bytes_read, kYUV12Size); |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_ptr<uint8[]> yuv_bytes_; | 61 scoped_ptr<uint8_t[]> yuv_bytes_; |
| 62 scoped_ptr<uint8[]> rgb_bytes_converted_; | 62 scoped_ptr<uint8_t[]> rgb_bytes_converted_; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); | 65 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { | 68 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { |
| 69 ASSERT_TRUE(base::CPU().has_sse()); | 69 ASSERT_TRUE(base::CPU().has_sse()); |
| 70 | 70 |
| 71 base::TimeTicks start = base::TimeTicks::Now(); | 71 base::TimeTicks start = base::TimeTicks::Now(); |
| 72 for (int i = 0; i < kPerfTestIterations; ++i) { | 72 for (int i = 0; i < kPerfTestIterations; ++i) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); | 207 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); |
| 208 perf_test::PrintResult( | 208 perf_test::PrintResult( |
| 209 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", | 209 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", |
| 210 kPerfTestIterations / total_time_seconds, "runs/s", true); | 210 kPerfTestIterations / total_time_seconds, "runs/s", true); |
| 211 } | 211 } |
| 212 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD) | 212 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD) |
| 213 | 213 |
| 214 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) | 214 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) |
| 215 | 215 |
| 216 } // namespace media | 216 } // namespace media |
| OLD | NEW |