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

Side by Side Diff: media/base/demuxer_perftest.cc

Issue 2738503005: Created battor.tough_energy_cases (without dcurtis's change)
Patch Set: Reupload Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/test/scoped_task_scheduler.h"
16 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 16 #include "base/time/time.h"
18 #include "build/build_config.h" 17 #include "build/build_config.h"
19 #include "media/base/media.h" 18 #include "media/base/media.h"
20 #include "media/base/media_log.h" 19 #include "media/base/media_log.h"
21 #include "media/base/media_tracks.h" 20 #include "media/base/media_tracks.h"
22 #include "media/base/test_data_util.h" 21 #include "media/base/test_data_util.h"
23 #include "media/base/timestamp_constants.h" 22 #include "media/base/timestamp_constants.h"
24 #include "media/filters/ffmpeg_demuxer.h" 23 #include "media/filters/ffmpeg_demuxer.h"
25 #include "media/filters/file_data_source.h" 24 #include "media/filters/file_data_source.h"
(...skipping 16 matching lines...) Expand all
42 void SetDuration(base::TimeDelta duration) override {} 41 void SetDuration(base::TimeDelta duration) override {}
43 void OnDemuxerError(media::PipelineStatus error) override {} 42 void OnDemuxerError(media::PipelineStatus error) override {}
44 void AddTextStream(media::DemuxerStream* text_stream, 43 void AddTextStream(media::DemuxerStream* text_stream,
45 const media::TextTrackConfig& config) override {} 44 const media::TextTrackConfig& config) override {}
46 void RemoveTextStream(media::DemuxerStream* text_stream) override {} 45 void RemoveTextStream(media::DemuxerStream* text_stream) override {}
47 46
48 private: 47 private:
49 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl); 48 DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl);
50 }; 49 };
51 50
52 static void QuitLoopWithStatus(base::Closure quit_cb, 51 static void QuitLoopWithStatus(base::MessageLoop* message_loop,
53 media::PipelineStatus status) { 52 media::PipelineStatus status) {
54 CHECK_EQ(status, media::PIPELINE_OK); 53 CHECK_EQ(status, media::PIPELINE_OK);
55 quit_cb.Run(); 54 message_loop->task_runner()->PostTask(
55 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
56 } 56 }
57 57
58 static void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 58 static void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
59 const std::vector<uint8_t>& init_data) { 59 const std::vector<uint8_t>& init_data) {
60 DVLOG(1) << "File is encrypted."; 60 VLOG(0) << "File is encrypted.";
61 } 61 }
62 62
63 static void OnMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks) { 63 static void OnMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks) {
64 DVLOG(1) << "Got media tracks info, tracks = " << tracks->tracks().size(); 64 VLOG(0) << "Got media tracks info, tracks = " << tracks->tracks().size();
65 } 65 }
66 66
67 typedef std::vector<media::DemuxerStream* > Streams; 67 typedef std::vector<media::DemuxerStream* > Streams;
68 68
69 // Simulates playback reading requirements by reading from each stream 69 // Simulates playback reading requirements by reading from each stream
70 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order. 70 // present in |demuxer| in as-close-to-monotonically-increasing timestamp order.
71 class StreamReader { 71 class StreamReader {
72 public: 72 public:
73 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter); 73 StreamReader(media::Demuxer* demuxer, bool enable_bitstream_converter);
74 ~StreamReader(); 74 ~StreamReader();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 last_read_timestamp_[i] < last_read_timestamp_[index]) { 170 last_read_timestamp_[i] < last_read_timestamp_[index]) {
171 index = i; 171 index = i;
172 } 172 }
173 } 173 }
174 CHECK_GE(index, 0) << "Couldn't find a stream to read"; 174 CHECK_GE(index, 0) << "Couldn't find a stream to read";
175 return index; 175 return index;
176 } 176 }
177 177
178 static void RunDemuxerBenchmark(const std::string& filename) { 178 static void RunDemuxerBenchmark(const std::string& filename) {
179 base::FilePath file_path(GetTestDataFilePath(filename)); 179 base::FilePath file_path(GetTestDataFilePath(filename));
180 base::TimeDelta total_time; 180 double total_time = 0.0;
181 for (int i = 0; i < kBenchmarkIterations; ++i) { 181 for (int i = 0; i < kBenchmarkIterations; ++i) {
182 // Setup. 182 // Setup.
183 base::test::ScopedTaskScheduler scoped_task_scheduler; 183 base::MessageLoop message_loop;
184 DemuxerHostImpl demuxer_host; 184 DemuxerHostImpl demuxer_host;
185 FileDataSource data_source; 185 FileDataSource data_source;
186 ASSERT_TRUE(data_source.Initialize(file_path)); 186 ASSERT_TRUE(data_source.Initialize(file_path));
187 187
188 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 188 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
189 base::Bind(&OnEncryptedMediaInitData); 189 base::Bind(&OnEncryptedMediaInitData);
190 Demuxer::MediaTracksUpdatedCB tracks_updated_cb = 190 Demuxer::MediaTracksUpdatedCB tracks_updated_cb =
191 base::Bind(&OnMediaTracksUpdated); 191 base::Bind(&OnMediaTracksUpdated);
192 FFmpegDemuxer demuxer(base::ThreadTaskRunnerHandle::Get(), &data_source, 192 FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source,
193 encrypted_media_init_data_cb, tracks_updated_cb, 193 encrypted_media_init_data_cb, tracks_updated_cb,
194 new MediaLog()); 194 new MediaLog());
195 195
196 { 196 demuxer.Initialize(&demuxer_host,
197 base::RunLoop run_loop; 197 base::Bind(&QuitLoopWithStatus, &message_loop),
198 demuxer.Initialize( 198 false);
199 &demuxer_host, 199 base::RunLoop().Run();
200 base::Bind(&QuitLoopWithStatus, run_loop.QuitClosure()), false);
201 run_loop.Run();
202 }
203
204 StreamReader stream_reader(&demuxer, false); 200 StreamReader stream_reader(&demuxer, false);
205 201
206 // Benchmark. 202 // Benchmark.
207 base::TimeTicks start = base::TimeTicks::Now(); 203 base::TimeTicks start = base::TimeTicks::Now();
208 while (!stream_reader.IsDone()) 204 while (!stream_reader.IsDone()) {
209 stream_reader.Read(); 205 stream_reader.Read();
210 total_time += base::TimeTicks::Now() - start; 206 }
207 base::TimeTicks end = base::TimeTicks::Now();
208 total_time += (end - start).InSecondsF();
211 demuxer.Stop(); 209 demuxer.Stop();
212 base::RunLoop().RunUntilIdle(); 210 QuitLoopWithStatus(&message_loop, PIPELINE_OK);
211 base::RunLoop().Run();
213 } 212 }
214 213
215 perf_test::PrintResult("demuxer_bench", "", filename, 214 perf_test::PrintResult("demuxer_bench",
216 kBenchmarkIterations / total_time.InSecondsF(), 215 "",
217 "runs/s", true); 216 filename,
217 kBenchmarkIterations / total_time,
218 "runs/s",
219 true);
218 } 220 }
219 221
220 #if defined(OS_WIN) 222 #if defined(OS_WIN)
221 // http://crbug.com/399002 223 // http://crbug.com/399002
222 #define MAYBE_Demuxer DISABLED_Demuxer 224 #define MAYBE_Demuxer DISABLED_Demuxer
223 #else 225 #else
224 #define MAYBE_Demuxer Demuxer 226 #define MAYBE_Demuxer Demuxer
225 #endif 227 #endif
226 TEST(DemuxerPerfTest, MAYBE_Demuxer) { 228 TEST(DemuxerPerfTest, MAYBE_Demuxer) {
227 RunDemuxerBenchmark("bear.ogv"); 229 RunDemuxerBenchmark("bear.ogv");
228 RunDemuxerBenchmark("bear-640x360.webm"); 230 RunDemuxerBenchmark("bear-640x360.webm");
229 RunDemuxerBenchmark("sfx_s16le.wav"); 231 RunDemuxerBenchmark("sfx_s16le.wav");
230 RunDemuxerBenchmark("bear.flac"); 232 RunDemuxerBenchmark("bear.flac");
231 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 233 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
232 RunDemuxerBenchmark("bear-1280x720.mp4"); 234 RunDemuxerBenchmark("bear-1280x720.mp4");
233 RunDemuxerBenchmark("sfx.mp3"); 235 RunDemuxerBenchmark("sfx.mp3");
234 #endif 236 #endif
235 #if BUILDFLAG(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS) 237 #if BUILDFLAG(USE_PROPRIETARY_CODECS) && defined(OS_CHROMEOS)
236 RunDemuxerBenchmark("bear.avi"); 238 RunDemuxerBenchmark("bear.avi");
237 #endif 239 #endif
238 } 240 }
239 241
240 } // namespace media 242 } // namespace media
OLDNEW
« no previous file with comments | « chromecast/media/cma/backend/audio_video_pipeline_device_unittest.cc ('k') | media/filters/blocking_url_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698