| 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 <memory> |
| 6 |
| 5 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 6 #include "media/base/audio_converter.h" | 8 #include "media/base/audio_converter.h" |
| 7 #include "media/base/fake_audio_render_callback.h" | 9 #include "media/base/fake_audio_render_callback.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/perf/perf_test.h" | 11 #include "testing/perf/perf_test.h" |
| 10 | 12 |
| 11 namespace media { | 13 namespace media { |
| 12 | 14 |
| 13 static const int kBenchmarkIterations = 200000; | 15 static const int kBenchmarkIterations = 200000; |
| 14 | 16 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 25 } | 27 } |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 void RunConvertBenchmark(const AudioParameters& in_params, | 30 void RunConvertBenchmark(const AudioParameters& in_params, |
| 29 const AudioParameters& out_params, | 31 const AudioParameters& out_params, |
| 30 bool fifo, | 32 bool fifo, |
| 31 const std::string& trace_name) { | 33 const std::string& trace_name) { |
| 32 NullInputProvider fake_input1; | 34 NullInputProvider fake_input1; |
| 33 NullInputProvider fake_input2; | 35 NullInputProvider fake_input2; |
| 34 NullInputProvider fake_input3; | 36 NullInputProvider fake_input3; |
| 35 scoped_ptr<AudioBus> output_bus = AudioBus::Create(out_params); | 37 std::unique_ptr<AudioBus> output_bus = AudioBus::Create(out_params); |
| 36 | 38 |
| 37 AudioConverter converter(in_params, out_params, !fifo); | 39 AudioConverter converter(in_params, out_params, !fifo); |
| 38 converter.AddInput(&fake_input1); | 40 converter.AddInput(&fake_input1); |
| 39 converter.AddInput(&fake_input2); | 41 converter.AddInput(&fake_input2); |
| 40 converter.AddInput(&fake_input3); | 42 converter.AddInput(&fake_input3); |
| 41 | 43 |
| 42 base::TimeTicks start = base::TimeTicks::Now(); | 44 base::TimeTicks start = base::TimeTicks::Now(); |
| 43 for (int i = 0; i < kBenchmarkIterations; ++i) { | 45 for (int i = 0; i < kBenchmarkIterations; ++i) { |
| 44 converter.Convert(output_bus.get()); | 46 converter.Convert(output_bus.get()); |
| 45 } | 47 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 70 2048); | 72 2048); |
| 71 AudioParameters output_params( | 73 AudioParameters output_params( |
| 72 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 44100, 16, 440); | 74 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 44100, 16, 440); |
| 73 | 75 |
| 74 RunConvertBenchmark(input_params, output_params, true, "convert_fifo_only"); | 76 RunConvertBenchmark(input_params, output_params, true, "convert_fifo_only"); |
| 75 RunConvertBenchmark(input_params, output_params, false, | 77 RunConvertBenchmark(input_params, output_params, false, |
| 76 "convert_pass_through"); | 78 "convert_pass_through"); |
| 77 } | 79 } |
| 78 | 80 |
| 79 } // namespace media | 81 } // namespace media |
| OLD | NEW |