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

Unified Diff: remoting/test/fake_socket_factory.cc

Issue 2369243002: Report network stats in the scroll performance tests (Closed)
Patch Set: Created 4 years, 3 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
Index: remoting/test/fake_socket_factory.cc
diff --git a/remoting/test/fake_socket_factory.cc b/remoting/test/fake_socket_factory.cc
index 39a9e862855a0dce3d809bb1c6925a9cf8070317..8223e356603731629782b4a896e1a3bc144f98a5 100644
--- a/remoting/test/fake_socket_factory.cc
+++ b/remoting/test/fake_socket_factory.cc
@@ -176,8 +176,7 @@ FakePacketSocketFactory::PendingPacket::PendingPacket(
FakePacketSocketFactory::PendingPacket::PendingPacket(
const PendingPacket& other) = default;
-FakePacketSocketFactory::PendingPacket::~PendingPacket() {
-}
+FakePacketSocketFactory::PendingPacket::~PendingPacket() {}
FakePacketSocketFactory::FakePacketSocketFactory(
FakeNetworkDispatcher* dispatcher)
@@ -309,6 +308,9 @@ void FakePacketSocketFactory::ReceivePacket(
if (delay < base::TimeDelta())
delay = base::TimeDelta();
+ total_delay_ += delay;
+ ++total_packets_received_;
+
// Put the packet to the |pending_packets_| and post a task for
// DoReceivePackets(). Note that the DoReceivePackets() task posted here may
// deliver a different packet, not the one added to the queue here. This
@@ -347,4 +349,14 @@ void FakePacketSocketFactory::DoReceivePacket() {
iter->second.Run(packet.from, packet.to, packet.data, packet.data_size);
}
+void FakePacketSocketFactory::ResetStats() {
+ total_packets_received_ = 0;
+ total_delay_ = base::TimeDelta();
+}
+
+base::TimeDelta FakePacketSocketFactory::GetAverageDelay() {
+ return total_packets_received_ > 0 ? (total_delay_ / total_packets_received_)
+ : base::TimeDelta();
+}
+
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698