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

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

Issue 70833002: Fix demuxer_perftest file paths and adjust various perftests' iterations/units. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 | « no previous file | 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 = 100; 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(*interleaved); 19 const int byte_size = sizeof(*interleaved);
20 20
21 base::TimeTicks start = base::TimeTicks::HighResNow(); 21 base::TimeTicks start = base::TimeTicks::HighResNow();
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_seconds = 25 double total_time_milliseconds =
26 (base::TimeTicks::HighResNow() - start).InSecondsF(); 26 (base::TimeTicks::HighResNow() - 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 kBenchmarkIterations / total_time_seconds, "runs/s", true); 29 total_time_milliseconds / kBenchmarkIterations, "ms", true);
30 30
31 start = base::TimeTicks::HighResNow(); 31 start = base::TimeTicks::HighResNow();
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_seconds = (base::TimeTicks::HighResNow() - start).InSecondsF(); 35 total_time_milliseconds =
36 (base::TimeTicks::HighResNow() - start).InMillisecondsF();
36 perf_test::PrintResult( 37 perf_test::PrintResult(
37 "audio_bus_from_interleaved", "", trace_name, 38 "audio_bus_from_interleaved", "", trace_name,
38 kBenchmarkIterations / total_time_seconds, "runs/s", true); 39 total_time_milliseconds / kBenchmarkIterations, "ms", true);
39 } 40 }
40 41
41 // Benchmark the FromInterleaved() and ToInterleaved() methods. 42 // Benchmark the FromInterleaved() and ToInterleaved() methods.
42 TEST(AudioBusPerfTest, Interleave) { 43 TEST(AudioBusPerfTest, Interleave) {
43 scoped_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120); 44 scoped_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120);
44 FakeAudioRenderCallback callback(0.2); 45 FakeAudioRenderCallback callback(0.2);
45 callback.Render(bus.get(), 0); 46 callback.Render(bus.get(), 0);
46 47
47 RunInterleaveBench<int8>(bus.get(), "int8"); 48 RunInterleaveBench<int8>(bus.get(), "int8");
48 RunInterleaveBench<int16>(bus.get(), "int16"); 49 RunInterleaveBench<int16>(bus.get(), "int16");
49 RunInterleaveBench<int32>(bus.get(), "int32"); 50 RunInterleaveBench<int32>(bus.get(), "int32");
50 } 51 }
51 52
52 } // namespace media 53 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_converter_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698