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

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: Rebase. 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
« no previous file with comments | « 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 562d760b8dc17cc6cbd99dbe2f388034211dd9b8..f5443cc4db1c0ed7556ec1a5127e185dcd274d7b 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 {
@@ -387,4 +388,60 @@ TEST_F(AudioBusTest, Scale) {
}
}
+// 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
« no previous file with comments | « media/base/audio_bus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698