OLD | NEW |
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_converter.h" | 6 #include "media/base/audio_converter.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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 NullInputProvider fake_input1; | 32 NullInputProvider fake_input1; |
33 NullInputProvider fake_input2; | 33 NullInputProvider fake_input2; |
34 NullInputProvider fake_input3; | 34 NullInputProvider fake_input3; |
35 scoped_ptr<AudioBus> output_bus = AudioBus::Create(out_params); | 35 scoped_ptr<AudioBus> output_bus = AudioBus::Create(out_params); |
36 | 36 |
37 AudioConverter converter(in_params, out_params, !fifo); | 37 AudioConverter converter(in_params, out_params, !fifo); |
38 converter.AddInput(&fake_input1); | 38 converter.AddInput(&fake_input1); |
39 converter.AddInput(&fake_input2); | 39 converter.AddInput(&fake_input2); |
40 converter.AddInput(&fake_input3); | 40 converter.AddInput(&fake_input3); |
41 | 41 |
42 base::TimeTicks start = base::TimeTicks::HighResNow(); | 42 base::TimeTicks start = base::TimeTicks::Now(); |
43 for (int i = 0; i < kBenchmarkIterations; ++i) { | 43 for (int i = 0; i < kBenchmarkIterations; ++i) { |
44 converter.Convert(output_bus.get()); | 44 converter.Convert(output_bus.get()); |
45 } | 45 } |
46 double runs_per_second = kBenchmarkIterations / | 46 double runs_per_second = kBenchmarkIterations / |
47 (base::TimeTicks::HighResNow() - start).InSecondsF(); | 47 (base::TimeTicks::Now() - start).InSecondsF(); |
48 perf_test::PrintResult( | 48 perf_test::PrintResult( |
49 "audio_converter", "", trace_name, runs_per_second, "runs/s", true); | 49 "audio_converter", "", trace_name, runs_per_second, "runs/s", true); |
50 } | 50 } |
51 | 51 |
52 TEST(AudioConverterPerfTest, ConvertBenchmark) { | 52 TEST(AudioConverterPerfTest, ConvertBenchmark) { |
53 // Create input and output parameters to convert between the two most common | 53 // Create input and output parameters to convert between the two most common |
54 // sets of parameters (as indicated via UMA data). | 54 // sets of parameters (as indicated via UMA data). |
55 AudioParameters input_params( | 55 AudioParameters input_params( |
56 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO, 48000, 16, 2048); | 56 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO, 48000, 16, 2048); |
57 AudioParameters output_params( | 57 AudioParameters output_params( |
(...skipping 12 matching lines...) Expand all Loading... |
70 2048); | 70 2048); |
71 AudioParameters output_params( | 71 AudioParameters output_params( |
72 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 44100, 16, 440); | 72 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 44100, 16, 440); |
73 | 73 |
74 RunConvertBenchmark(input_params, output_params, true, "convert_fifo_only"); | 74 RunConvertBenchmark(input_params, output_params, true, "convert_fifo_only"); |
75 RunConvertBenchmark(input_params, output_params, false, | 75 RunConvertBenchmark(input_params, output_params, false, |
76 "convert_pass_through"); | 76 "convert_pass_through"); |
77 } | 77 } |
78 | 78 |
79 } // namespace media | 79 } // namespace media |
OLD | NEW |