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

Side by Side Diff: media/cast/test/cast_benchmarks.cc

Issue 2086353002: Remove calls to deprecated MessageLoop methods in media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « media/cast/sender/h264_vt_encoder_unittest.cc ('k') | media/cast/test/receiver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This program benchmarks the theoretical throughput of the cast library. 5 // This program benchmarks the theoretical throughput of the cast library.
6 // It runs using a fake clock, simulated network and fake codecs. This allows 6 // It runs using a fake clock, simulated network and fake codecs. This allows
7 // tests to run much faster than real time. 7 // tests to run much faster than real time.
8 // To run the program, run: 8 // To run the program, run:
9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc 9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc
10 // This may take a while, when it is done, you can view the data with 10 // This may take a while, when it is done, you can view the data with
(...skipping 19 matching lines...) Expand all
30 #include <vector> 30 #include <vector>
31 31
32 #include "base/at_exit.h" 32 #include "base/at_exit.h"
33 #include "base/bind.h" 33 #include "base/bind.h"
34 #include "base/bind_helpers.h" 34 #include "base/bind_helpers.h"
35 #include "base/command_line.h" 35 #include "base/command_line.h"
36 #include "base/debug/profiler.h" 36 #include "base/debug/profiler.h"
37 #include "base/memory/ptr_util.h" 37 #include "base/memory/ptr_util.h"
38 #include "base/memory/weak_ptr.h" 38 #include "base/memory/weak_ptr.h"
39 #include "base/run_loop.h" 39 #include "base/run_loop.h"
40 #include "base/single_thread_task_runner.h"
40 #include "base/stl_util.h" 41 #include "base/stl_util.h"
41 #include "base/strings/string_number_conversions.h" 42 #include "base/strings/string_number_conversions.h"
42 #include "base/strings/stringprintf.h" 43 #include "base/strings/stringprintf.h"
43 #include "base/test/simple_test_tick_clock.h" 44 #include "base/test/simple_test_tick_clock.h"
44 #include "base/threading/thread.h" 45 #include "base/threading/thread.h"
45 #include "base/time/tick_clock.h" 46 #include "base/time/tick_clock.h"
46 #include "media/base/audio_bus.h" 47 #include "media/base/audio_bus.h"
47 #include "media/base/fake_single_thread_task_runner.h" 48 #include "media/base/fake_single_thread_task_runner.h"
48 #include "media/base/video_frame.h" 49 #include "media/base/video_frame.h"
49 #include "media/cast/cast_config.h" 50 #include "media/cast/cast_config.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 double accuracy, 649 double accuracy,
649 std::vector<linked_ptr<base::Thread> >* threads) { 650 std::vector<linked_ptr<base::Thread> >* threads) {
650 static int thread_num = 0; 651 static int thread_num = 0;
651 if (x > max) return; 652 if (x > max) return;
652 if (skip > max) { 653 if (skip > max) {
653 if (y > x) return; 654 if (y > x) return;
654 SearchVector ab = a.blend(b, static_cast<double>(x) / max); 655 SearchVector ab = a.blend(b, static_cast<double>(x) / max);
655 SearchVector ac = a.blend(c, static_cast<double>(x) / max); 656 SearchVector ac = a.blend(c, static_cast<double>(x) / max);
656 SearchVector v = ab.blend(ac, x == y ? 1.0 : static_cast<double>(y) / x); 657 SearchVector v = ab.blend(ac, x == y ? 1.0 : static_cast<double>(y) / x);
657 thread_num++; 658 thread_num++;
658 (*threads)[thread_num % threads->size()]->message_loop()->PostTask( 659 (*threads)[thread_num % threads->size()]
659 FROM_HERE, 660 ->message_loop()
660 base::Bind(&CastBenchmark::BinarySearch, 661 ->task_runner()
661 base::Unretained(this), 662 ->PostTask(FROM_HERE,
662 v, 663 base::Bind(&CastBenchmark::BinarySearch,
663 accuracy)); 664 base::Unretained(this), v, accuracy));
664 } else { 665 } else {
665 skip *= 2; 666 skip *= 2;
666 SpanningSearch(max, x, y, skip, a, b, c, accuracy, threads); 667 SpanningSearch(max, x, y, skip, a, b, c, accuracy, threads);
667 SpanningSearch(max, x + skip, y + skip, skip, a, b, c, accuracy, threads); 668 SpanningSearch(max, x + skip, y + skip, skip, a, b, c, accuracy, threads);
668 SpanningSearch(max, x + skip, y, skip, a, b, c, accuracy, threads); 669 SpanningSearch(max, x + skip, y, skip, a, b, c, accuracy, threads);
669 SpanningSearch(max, x, y + skip, skip, a, b, c, accuracy, threads); 670 SpanningSearch(max, x, y + skip, skip, a, b, c, accuracy, threads);
670 } 671 }
671 } 672 }
672 673
673 void Run() { 674 void Run() {
674 // Spanning search. 675 // Spanning search.
675 676
676 std::vector<linked_ptr<base::Thread> > threads; 677 std::vector<linked_ptr<base::Thread> > threads;
677 for (int i = 0; i < 16; i++) { 678 for (int i = 0; i < 16; i++) {
678 threads.push_back(make_linked_ptr(new base::Thread( 679 threads.push_back(make_linked_ptr(new base::Thread(
679 base::StringPrintf("cast_bench_thread_%d", i)))); 680 base::StringPrintf("cast_bench_thread_%d", i))));
680 threads[i]->Start(); 681 threads[i]->Start();
681 } 682 }
682 683
683 if (base::CommandLine::ForCurrentProcess()->HasSwitch("single-run")) { 684 if (base::CommandLine::ForCurrentProcess()->HasSwitch("single-run")) {
684 SearchVector a; 685 SearchVector a;
685 a.bitrate.base = 100.0; 686 a.bitrate.base = 100.0;
686 a.bitrate.grade = 1.0; 687 a.bitrate.grade = 1.0;
687 a.latency.grade = 1.0; 688 a.latency.grade = 1.0;
688 a.packet_drop.grade = 1.0; 689 a.packet_drop.grade = 1.0;
689 threads[0]->message_loop()->PostTask( 690 threads[0]->message_loop()->task_runner()->PostTask(
690 FROM_HERE, 691 FROM_HERE, base::Bind(base::IgnoreResult(&CastBenchmark::RunOnePoint),
691 base::Bind(base::IgnoreResult(&CastBenchmark::RunOnePoint), 692 base::Unretained(this), a, 1.0));
692 base::Unretained(this),
693 a,
694 1.0));
695 } else { 693 } else {
696 SearchVector a, b, c; 694 SearchVector a, b, c;
697 a.bitrate.base = b.bitrate.base = c.bitrate.base = 100.0; 695 a.bitrate.base = b.bitrate.base = c.bitrate.base = 100.0;
698 a.bitrate.grade = 1.0; 696 a.bitrate.grade = 1.0;
699 b.latency.grade = 1.0; 697 b.latency.grade = 1.0;
700 c.packet_drop.grade = 1.0; 698 c.packet_drop.grade = 1.0;
701 699
702 SpanningSearch(512, 700 SpanningSearch(512,
703 0, 701 0,
704 0, 702 0,
(...skipping 24 matching lines...) Expand all
729 media::cast::CastBenchmark benchmark; 727 media::cast::CastBenchmark benchmark;
730 if (getenv("PROFILE_FILE")) { 728 if (getenv("PROFILE_FILE")) {
731 std::string profile_file(getenv("PROFILE_FILE")); 729 std::string profile_file(getenv("PROFILE_FILE"));
732 base::debug::StartProfiling(profile_file); 730 base::debug::StartProfiling(profile_file);
733 benchmark.Run(); 731 benchmark.Run();
734 base::debug::StopProfiling(); 732 base::debug::StopProfiling();
735 } else { 733 } else {
736 benchmark.Run(); 734 benchmark.Run();
737 } 735 }
738 } 736 }
OLDNEW
« no previous file with comments | « media/cast/sender/h264_vt_encoder_unittest.cc ('k') | media/cast/test/receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698