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

Side by Side Diff: media/base/audio_bus_perftest.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 years, 7 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 | « media/base/audio_bus.cc ('k') | media/base/audio_bus_unittest.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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 #include <memory>
6 7
7 #include "base/time/time.h" 8 #include "base/time/time.h"
8 #include "media/base/audio_bus.h" 9 #include "media/base/audio_bus.h"
9 #include "media/base/fake_audio_render_callback.h" 10 #include "media/base/fake_audio_render_callback.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/perf/perf_test.h" 12 #include "testing/perf/perf_test.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 static const int kBenchmarkIterations = 20; 16 static const int kBenchmarkIterations = 20;
16 17
17 template <typename T> 18 template <typename T>
18 void RunInterleaveBench(AudioBus* bus, const std::string& trace_name) { 19 void RunInterleaveBench(AudioBus* bus, const std::string& trace_name) {
19 const int frame_size = bus->frames() * bus->channels(); 20 const int frame_size = bus->frames() * bus->channels();
20 scoped_ptr<T[]> interleaved(new T[frame_size]); 21 std::unique_ptr<T[]> interleaved(new T[frame_size]);
21 const int byte_size = sizeof(T); 22 const int byte_size = sizeof(T);
22 23
23 base::TimeTicks start = base::TimeTicks::Now(); 24 base::TimeTicks start = base::TimeTicks::Now();
24 for (int i = 0; i < kBenchmarkIterations; ++i) { 25 for (int i = 0; i < kBenchmarkIterations; ++i) {
25 bus->ToInterleaved(bus->frames(), byte_size, interleaved.get()); 26 bus->ToInterleaved(bus->frames(), byte_size, interleaved.get());
26 } 27 }
27 double total_time_milliseconds = 28 double total_time_milliseconds =
28 (base::TimeTicks::Now() - start).InMillisecondsF(); 29 (base::TimeTicks::Now() - start).InMillisecondsF();
29 perf_test::PrintResult( 30 perf_test::PrintResult(
30 "audio_bus_to_interleaved", "", trace_name, 31 "audio_bus_to_interleaved", "", trace_name,
31 total_time_milliseconds / kBenchmarkIterations, "ms", true); 32 total_time_milliseconds / kBenchmarkIterations, "ms", true);
32 33
33 start = base::TimeTicks::Now(); 34 start = base::TimeTicks::Now();
34 for (int i = 0; i < kBenchmarkIterations; ++i) { 35 for (int i = 0; i < kBenchmarkIterations; ++i) {
35 bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size); 36 bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size);
36 } 37 }
37 total_time_milliseconds = 38 total_time_milliseconds =
38 (base::TimeTicks::Now() - start).InMillisecondsF(); 39 (base::TimeTicks::Now() - start).InMillisecondsF();
39 perf_test::PrintResult( 40 perf_test::PrintResult(
40 "audio_bus_from_interleaved", "", trace_name, 41 "audio_bus_from_interleaved", "", trace_name,
41 total_time_milliseconds / kBenchmarkIterations, "ms", true); 42 total_time_milliseconds / kBenchmarkIterations, "ms", true);
42 } 43 }
43 44
44 // Benchmark the FromInterleaved() and ToInterleaved() methods. 45 // Benchmark the FromInterleaved() and ToInterleaved() methods.
45 TEST(AudioBusPerfTest, Interleave) { 46 TEST(AudioBusPerfTest, Interleave) {
46 scoped_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120); 47 std::unique_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120);
47 FakeAudioRenderCallback callback(0.2); 48 FakeAudioRenderCallback callback(0.2);
48 callback.Render(bus.get(), 0, 0); 49 callback.Render(bus.get(), 0, 0);
49 50
50 RunInterleaveBench<int8_t>(bus.get(), "int8_t"); 51 RunInterleaveBench<int8_t>(bus.get(), "int8_t");
51 RunInterleaveBench<int16_t>(bus.get(), "int16_t"); 52 RunInterleaveBench<int16_t>(bus.get(), "int16_t");
52 RunInterleaveBench<int32_t>(bus.get(), "int32_t"); 53 RunInterleaveBench<int32_t>(bus.get(), "int32_t");
53 } 54 }
54 55
55 } // namespace media 56 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.cc ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698