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

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

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

Powered by Google App Engine
This is Rietveld 408576698