| Index: media/base/demuxer_perftest.cc
|
| diff --git a/media/base/demuxer_perftest.cc b/media/base/demuxer_perftest.cc
|
| index b04db50b47e65cd30e295ae24f2249045a247ae0..45b449912b66321977428dc4c39a6743dc406ff1 100644
|
| --- a/media/base/demuxer_perftest.cc
|
| +++ b/media/base/demuxer_perftest.cc
|
| @@ -12,7 +12,6 @@
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| #include "base/strings/string_number_conversions.h"
|
| -#include "base/test/scoped_task_scheduler.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| @@ -49,19 +48,20 @@
|
| DISALLOW_COPY_AND_ASSIGN(DemuxerHostImpl);
|
| };
|
|
|
| -static void QuitLoopWithStatus(base::Closure quit_cb,
|
| +static void QuitLoopWithStatus(base::MessageLoop* message_loop,
|
| media::PipelineStatus status) {
|
| CHECK_EQ(status, media::PIPELINE_OK);
|
| - quit_cb.Run();
|
| + message_loop->task_runner()->PostTask(
|
| + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
| }
|
|
|
| static void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
|
| const std::vector<uint8_t>& init_data) {
|
| - DVLOG(1) << "File is encrypted.";
|
| + VLOG(0) << "File is encrypted.";
|
| }
|
|
|
| static void OnMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks) {
|
| - DVLOG(1) << "Got media tracks info, tracks = " << tracks->tracks().size();
|
| + VLOG(0) << "Got media tracks info, tracks = " << tracks->tracks().size();
|
| }
|
|
|
| typedef std::vector<media::DemuxerStream* > Streams;
|
| @@ -177,10 +177,10 @@
|
|
|
| static void RunDemuxerBenchmark(const std::string& filename) {
|
| base::FilePath file_path(GetTestDataFilePath(filename));
|
| - base::TimeDelta total_time;
|
| + double total_time = 0.0;
|
| for (int i = 0; i < kBenchmarkIterations; ++i) {
|
| // Setup.
|
| - base::test::ScopedTaskScheduler scoped_task_scheduler;
|
| + base::MessageLoop message_loop;
|
| DemuxerHostImpl demuxer_host;
|
| FileDataSource data_source;
|
| ASSERT_TRUE(data_source.Initialize(file_path));
|
| @@ -189,32 +189,34 @@
|
| base::Bind(&OnEncryptedMediaInitData);
|
| Demuxer::MediaTracksUpdatedCB tracks_updated_cb =
|
| base::Bind(&OnMediaTracksUpdated);
|
| - FFmpegDemuxer demuxer(base::ThreadTaskRunnerHandle::Get(), &data_source,
|
| + FFmpegDemuxer demuxer(message_loop.task_runner(), &data_source,
|
| encrypted_media_init_data_cb, tracks_updated_cb,
|
| new MediaLog());
|
|
|
| - {
|
| - base::RunLoop run_loop;
|
| - demuxer.Initialize(
|
| - &demuxer_host,
|
| - base::Bind(&QuitLoopWithStatus, run_loop.QuitClosure()), false);
|
| - run_loop.Run();
|
| - }
|
| -
|
| + demuxer.Initialize(&demuxer_host,
|
| + base::Bind(&QuitLoopWithStatus, &message_loop),
|
| + false);
|
| + base::RunLoop().Run();
|
| StreamReader stream_reader(&demuxer, false);
|
|
|
| // Benchmark.
|
| base::TimeTicks start = base::TimeTicks::Now();
|
| - while (!stream_reader.IsDone())
|
| + while (!stream_reader.IsDone()) {
|
| stream_reader.Read();
|
| - total_time += base::TimeTicks::Now() - start;
|
| + }
|
| + base::TimeTicks end = base::TimeTicks::Now();
|
| + total_time += (end - start).InSecondsF();
|
| demuxer.Stop();
|
| - base::RunLoop().RunUntilIdle();
|
| - }
|
| -
|
| - perf_test::PrintResult("demuxer_bench", "", filename,
|
| - kBenchmarkIterations / total_time.InSecondsF(),
|
| - "runs/s", true);
|
| + QuitLoopWithStatus(&message_loop, PIPELINE_OK);
|
| + base::RunLoop().Run();
|
| + }
|
| +
|
| + perf_test::PrintResult("demuxer_bench",
|
| + "",
|
| + filename,
|
| + kBenchmarkIterations / total_time,
|
| + "runs/s",
|
| + true);
|
| }
|
|
|
| #if defined(OS_WIN)
|
|
|