OLD | NEW |
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 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 36 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
37 #include "remoting/protocol/session_config.h" | 37 #include "remoting/protocol/session_config.h" |
38 #include "remoting/protocol/transport_context.h" | 38 #include "remoting/protocol/transport_context.h" |
39 #include "remoting/protocol/video_frame_pump.h" | 39 #include "remoting/protocol/video_frame_pump.h" |
40 #include "remoting/protocol/video_renderer.h" | 40 #include "remoting/protocol/video_renderer.h" |
41 #include "remoting/signaling/fake_signal_strategy.h" | 41 #include "remoting/signaling/fake_signal_strategy.h" |
42 #include "remoting/test/cyclic_frame_generator.h" | 42 #include "remoting/test/cyclic_frame_generator.h" |
43 #include "remoting/test/fake_network_dispatcher.h" | 43 #include "remoting/test/fake_network_dispatcher.h" |
44 #include "remoting/test/fake_port_allocator.h" | 44 #include "remoting/test/fake_port_allocator.h" |
45 #include "remoting/test/fake_socket_factory.h" | 45 #include "remoting/test/fake_socket_factory.h" |
| 46 #include "remoting/test/scroll_frame_generator.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
47 | 48 |
48 namespace remoting { | 49 namespace remoting { |
49 | 50 |
50 using protocol::ChannelConfig; | 51 using protocol::ChannelConfig; |
51 | 52 |
52 namespace { | 53 namespace { |
53 | 54 |
54 const char kHostJid[] = "host_jid@example.com/host"; | 55 const char kHostJid[] = "host_jid@example.com/host"; |
55 const char kHostOwner[] = "jane.doe@example.com"; | 56 const char kHostOwner[] = "jane.doe@example.com"; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 client_->Start(client_signaling_.get(), client_auth_config, | 409 client_->Start(client_signaling_.get(), client_auth_config, |
409 transport_context, kHostJid, std::string()); | 410 transport_context, kHostJid, std::string()); |
410 } | 411 } |
411 | 412 |
412 void FetchPin( | 413 void FetchPin( |
413 bool pairing_supported, | 414 bool pairing_supported, |
414 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 415 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
415 secret_fetched_callback.Run(kHostPin); | 416 secret_fetched_callback.Run(kHostPin); |
416 } | 417 } |
417 | 418 |
418 void MeasureTotalLatency(bool webrtc) { | 419 void MeasureTotalLatency(bool use_webrtc) { |
419 scoped_refptr<test::CyclicFrameGenerator> frame_generator = | 420 scoped_refptr<test::CyclicFrameGenerator> frame_generator = |
420 test::CyclicFrameGenerator::Create(); | 421 test::CyclicFrameGenerator::Create(); |
421 frame_generator->set_draw_barcode(true); | 422 frame_generator->set_draw_barcode(true); |
422 | 423 |
423 desktop_environment_factory_.set_frame_generator(base::Bind( | 424 desktop_environment_factory_.set_frame_generator(base::Bind( |
424 &test::CyclicFrameGenerator::GenerateFrame, frame_generator)); | 425 &test::CyclicFrameGenerator::GenerateFrame, frame_generator)); |
425 | 426 |
426 StartHostAndClient(webrtc, protocol::ChannelConfig::CODEC_VP8); | 427 StartHostAndClient(use_webrtc, protocol::ChannelConfig::CODEC_VP8); |
427 ASSERT_NO_FATAL_FAILURE(WaitConnected()); | 428 ASSERT_NO_FATAL_FAILURE(WaitConnected()); |
428 | 429 |
429 int skipped_frames = 0; | 430 int skipped_frames = 0; |
430 while (skipped_frames < 10) { | 431 while (skipped_frames < 10) { |
431 std::unique_ptr<webrtc::DesktopFrame> frame = ReceiveFrame(); | 432 std::unique_ptr<webrtc::DesktopFrame> frame = ReceiveFrame(); |
432 test::CyclicFrameGenerator::ChangeInfoList changes = | 433 test::CyclicFrameGenerator::ChangeInfoList changes = |
433 frame_generator->GetChangeList(frame.get()); | 434 frame_generator->GetChangeList(frame.get()); |
434 skipped_frames += changes.size(); | 435 skipped_frames += changes.size(); |
435 } | 436 } |
436 | 437 |
(...skipping 29 matching lines...) Expand all Loading... |
466 VLOG(0) << "Average latency for big frames: " | 467 VLOG(0) << "Average latency for big frames: " |
467 << (total_latency_big_frames / big_frame_count).InMillisecondsF(); | 468 << (total_latency_big_frames / big_frame_count).InMillisecondsF(); |
468 | 469 |
469 if (small_frame_count) { | 470 if (small_frame_count) { |
470 VLOG(0) | 471 VLOG(0) |
471 << "Average latency for small frames: " | 472 << "Average latency for small frames: " |
472 << (total_latency_small_frames / small_frame_count).InMillisecondsF(); | 473 << (total_latency_small_frames / small_frame_count).InMillisecondsF(); |
473 } | 474 } |
474 } | 475 } |
475 | 476 |
| 477 void MeasureScrollPerformance(bool use_webrtc) { |
| 478 scoped_refptr<test::ScrollFrameGenerator> frame_generator = |
| 479 new test::ScrollFrameGenerator(); |
| 480 |
| 481 desktop_environment_factory_.set_frame_generator(base::Bind( |
| 482 &test::ScrollFrameGenerator::GenerateFrame, frame_generator)); |
| 483 |
| 484 StartHostAndClient(use_webrtc, protocol::ChannelConfig::CODEC_VP8); |
| 485 ASSERT_NO_FATAL_FAILURE(WaitConnected()); |
| 486 |
| 487 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 488 const base::TimeDelta kWarmUpTime = base::TimeDelta::FromSeconds(2); |
| 489 while ((base::TimeTicks::Now() - start_time) < kWarmUpTime) { |
| 490 ReceiveFrame(); |
| 491 } |
| 492 |
| 493 // Run the test for 2 seconds. |
| 494 const base::TimeDelta kTestTime = base::TimeDelta::FromSeconds(2); |
| 495 |
| 496 int num_frames = 0; |
| 497 base::TimeDelta total_latency; |
| 498 start_time = base::TimeTicks::Now(); |
| 499 while ((base::TimeTicks::Now() - start_time) < kTestTime) { |
| 500 std::unique_ptr<webrtc::DesktopFrame> frame = ReceiveFrame(); |
| 501 ++num_frames; |
| 502 total_latency += frame_generator->GetFrameLatency(*frame); |
| 503 } |
| 504 |
| 505 VLOG(0) << "FPS: " |
| 506 << num_frames / (base::TimeTicks::Now() - start_time).InSecondsF(); |
| 507 |
| 508 VLOG(0) << "Average latency: " |
| 509 << (total_latency).InMillisecondsF() / num_frames; |
| 510 } |
| 511 |
476 base::MessageLoopForIO message_loop_; | 512 base::MessageLoopForIO message_loop_; |
477 | 513 |
478 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher_; | 514 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher_; |
479 | 515 |
480 base::Thread host_thread_; | 516 base::Thread host_thread_; |
481 base::Thread capture_thread_; | 517 base::Thread capture_thread_; |
482 base::Thread encode_thread_; | 518 base::Thread encode_thread_; |
483 base::Thread decode_thread_; | 519 base::Thread decode_thread_; |
484 FakeDesktopEnvironmentFactory desktop_environment_factory_; | 520 FakeDesktopEnvironmentFactory desktop_environment_factory_; |
485 | 521 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 } | 674 } |
639 | 675 |
640 TEST_P(ProtocolPerfTest, TotalLatencyIce) { | 676 TEST_P(ProtocolPerfTest, TotalLatencyIce) { |
641 MeasureTotalLatency(false); | 677 MeasureTotalLatency(false); |
642 } | 678 } |
643 | 679 |
644 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { | 680 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { |
645 MeasureTotalLatency(true); | 681 MeasureTotalLatency(true); |
646 } | 682 } |
647 | 683 |
| 684 TEST_P(ProtocolPerfTest, ScrollPerformanceIce) { |
| 685 MeasureScrollPerformance(false); |
| 686 } |
| 687 |
| 688 TEST_P(ProtocolPerfTest, ScrollPerformanceWebrtc) { |
| 689 MeasureScrollPerformance(true); |
| 690 } |
| 691 |
648 } // namespace remoting | 692 } // namespace remoting |
OLD | NEW |