BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / media / base / audio_bus_perftest.cc
blob71e81323950e46b4565081aac3bdedefc757a828
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
3 // found in the LICENSE file.
5 #include "base/time/time.h"
6 #include "media/base/audio_bus.h"
7 #include "media/base/fake_audio_render_callback.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/perf/perf_test.h"
11 namespace media {
13 static const int kBenchmarkIterations = 20;
15 template <typename T>
16 void RunInterleaveBench(AudioBus* bus, const std::string& trace_name) {
17 const int frame_size = bus->frames() * bus->channels();
18 scoped_ptr<T[]> interleaved(new T[frame_size]);
19 const int byte_size = sizeof(T);
21 base::TimeTicks start = base::TimeTicks::Now();
22 for (int i = 0; i < kBenchmarkIterations; ++i) {
23 bus->ToInterleaved(bus->frames(), byte_size, interleaved.get());
25 double total_time_milliseconds =
26 (base::TimeTicks::Now() - start).InMillisecondsF();
27 perf_test::PrintResult(
28 "audio_bus_to_interleaved", "", trace_name,
29 total_time_milliseconds / kBenchmarkIterations, "ms", true);
31 start = base::TimeTicks::Now();
32 for (int i = 0; i < kBenchmarkIterations; ++i) {
33 bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size);
35 total_time_milliseconds =
36 (base::TimeTicks::Now() - start).InMillisecondsF();
37 perf_test::PrintResult(
38 "audio_bus_from_interleaved", "", trace_name,
39 total_time_milliseconds / kBenchmarkIterations, "ms", true);
42 // Benchmark the FromInterleaved() and ToInterleaved() methods.
43 TEST(AudioBusPerfTest, Interleave) {
44 scoped_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120);
45 FakeAudioRenderCallback callback(0.2);
46 callback.Render(bus.get(), 0);
48 RunInterleaveBench<int8>(bus.get(), "int8");
49 RunInterleaveBench<int16>(bus.get(), "int16");
50 RunInterleaveBench<int32>(bus.get(), "int32");
53 } // namespace media