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

Unified Diff: media/base/audio_bus_unittest.cc

Issue 13730004: Remove static const from AudioBus interleave methods and optimize! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Linux benchmarks. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« media/base/audio_bus.cc ('K') | « media/base/audio_bus.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_bus_unittest.cc
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc
index 8c3a59f4efa103eb406302f7204c19e3d8350495..2b478139816b2dce1e589c256f797e3cadd05e60 100644
--- a/media/base/audio_bus_unittest.cc
+++ b/media/base/audio_bus_unittest.cc
@@ -9,6 +9,7 @@
#include "media/audio/audio_parameters.h"
#include "media/base/audio_bus.h"
#include "media/base/channel_layout.h"
+#include "media/base/fake_audio_render_callback.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
@@ -356,4 +357,61 @@ TEST_F(AudioBusTest, ToInterleavedPartial) {
kPartialFrames * sizeof(*kTestVectorInt16) * kTestVectorChannels), 0);
}
+
+// Benchmark the FromInterleaved() and ToInterleaved() methods.
+TEST_F(AudioBusTest, DISABLED_InterleaveBench) {
+ scoped_ptr<AudioBus> bus = AudioBus::Create(2, 48000 * 120);
+ const int frame_size = bus->frames() * bus->channels();
+ FakeAudioRenderCallback callback(0.2);
+ callback.Render(bus.get(), 0);
+ {
+ SCOPED_TRACE("uint8");
+ scoped_ptr<uint8> interleaved(new uint8[frame_size]);
+ const int byte_size = sizeof(*interleaved);
+
+ base::TimeTicks start = base::TimeTicks::HighResNow();
+ bus->ToInterleaved(bus->frames(), byte_size, interleaved.get());
+ double total_time_ms =
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("ToInterleaved uint8 took %.2fms.\n", total_time_ms);
+
+ start = base::TimeTicks::HighResNow();
+ bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size);
+ total_time_ms = (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("FromInterleaved uint8 took %.2fms.\n", total_time_ms);
+ }
+ {
+ SCOPED_TRACE("int16");
+ scoped_ptr<int16> interleaved(new int16[frame_size]);
+ const int byte_size = sizeof(*interleaved);
+
+ base::TimeTicks start = base::TimeTicks::HighResNow();
+ bus->ToInterleaved(bus->frames(), byte_size, interleaved.get());
+ double total_time_ms =
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("ToInterleaved int16 took %.2fms.\n", total_time_ms);
+
+ start = base::TimeTicks::HighResNow();
+ bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size);
+ total_time_ms = (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("FromInterleaved int16 took %.2fms.\n", total_time_ms);
+ }
+ {
+ SCOPED_TRACE("int32");
+ scoped_ptr<int32> interleaved(new int32[frame_size]);
+ const int byte_size = sizeof(*interleaved);
+
+ base::TimeTicks start = base::TimeTicks::HighResNow();
+ bus->ToInterleaved(bus->frames(), byte_size, interleaved.get());
+ double total_time_ms =
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("ToInterleaved int32 took %.2fms.\n", total_time_ms);
+
+ start = base::TimeTicks::HighResNow();
+ bus->FromInterleaved(interleaved.get(), bus->frames(), byte_size);
+ total_time_ms = (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("FromInterleaved int32 took %.2fms.\n", total_time_ms);
+ }
+}
+
} // namespace media
« media/base/audio_bus.cc ('K') | « media/base/audio_bus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698