diff options
4 files changed, 28 insertions, 28 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index da629089a6c..49733a5ba75 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2148,8 +2148,9 @@ std::chrono::duration<float> calculate_standard_deviation( void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, - uint32_t max_recv, bool json, - Stream &strm) { + uint32_t max_recv, + uint64_t recv_amount, + bool json, Stream &strm) { using namespace std::chrono; uint32_t i; @@ -2215,13 +2216,11 @@ void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets, } } - const uint64_t k_recv_amount = 4 * 1024 * 1024; // Receive amount in bytes - - const float k_recv_amount_mb = (float)k_recv_amount / (1024.0f * 1024.0f); + const float k_recv_amount_mb = (float)recv_amount / (1024.0f * 1024.0f); if (json) strm.Printf("\n ]\n },\n \"download_speed\" : {\n \"byte_size\" " ": %" PRIu64 ",\n \"results\" : [", - k_recv_amount); + recv_amount); else strm.Printf("Testing receiving %2.1fMB of data using varying receive " "packet sizes:\n", @@ -2238,7 +2237,7 @@ void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets, const auto start_time = steady_clock::now(); uint32_t bytes_read = 0; uint32_t packet_count = 0; - while (bytes_read < k_recv_amount) { + while (bytes_read < recv_amount) { StringExtractorGDBRemote response; SendPacketAndWaitForResponse(packet.GetString(), response, false); bytes_read += recv_size; @@ -2246,7 +2245,7 @@ void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets, } const auto end_time = steady_clock::now(); const auto total_time = end_time - start_time; - float mb_second = ((float)k_recv_amount) / + float mb_second = ((float)recv_amount) / duration<float>(total_time).count() / (1024.0 * 1024.0); float packets_per_second = diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 9e8954415f1..83162a662e0 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -323,7 +323,8 @@ public: bool SetNonStopMode(const bool enable); void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, - uint32_t max_recv, bool json, Stream &strm); + uint32_t max_recv, uint64_t recv_amount, bool json, + Stream &strm); // This packet is for testing the speed of the interface only. Both // the client and server need to support it, but this allows us to diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 4a3cc7f7a34..c0fbccb3e4f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4905,13 +4905,11 @@ public: const uint64_t max_send = m_max_send.GetOptionValue().GetCurrentValue(); const uint64_t max_recv = m_max_recv.GetOptionValue().GetCurrentValue(); const bool json = m_json.GetOptionValue().GetCurrentValue(); - if (output_stream_sp) - process->GetGDBRemote().TestPacketSpeed( - num_packets, max_send, max_recv, json, *output_stream_sp); - else { - process->GetGDBRemote().TestPacketSpeed( - num_packets, max_send, max_recv, json, result.GetOutputStream()); - } + const uint64_t k_recv_amount = + 4 * 1024 * 1024; // Receive amount in bytes + process->GetGDBRemote().TestPacketSpeed( + num_packets, max_send, max_recv, k_recv_amount, json, + output_stream_sp ? *output_stream_sp : result.GetOutputStream()); result.SetStatus(eReturnStatusSuccessFinishResult); return true; } diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 9db939ed591..84b354d7517 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -270,21 +270,23 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) { return; std::thread server_thread([&server] { - StringExtractorGDBRemote request; - PacketResult result = server.GetPacket(request); - if (result == PacketResult::ErrorDisconnected) - return; - ASSERT_EQ(PacketResult::Success, result); - StringRef ref = request.GetStringRef(); - ASSERT_TRUE(ref.consume_front("qSpeedTest:response_size:")); - int size; - ASSERT_FALSE(ref.consumeInteger(10, size)) << "ref: " << ref; - std::string response(size, 'X'); - ASSERT_EQ(PacketResult::Success, server.SendPacket(response)); + for (;;) { + StringExtractorGDBRemote request; + PacketResult result = server.GetPacket(request); + if (result == PacketResult::ErrorDisconnected) + return; + ASSERT_EQ(PacketResult::Success, result); + StringRef ref = request.GetStringRef(); + ASSERT_TRUE(ref.consume_front("qSpeedTest:response_size:")); + int size; + ASSERT_FALSE(ref.consumeInteger(10, size)) << "ref: " << ref; + std::string response(size, 'X'); + ASSERT_EQ(PacketResult::Success, server.SendPacket(response)); + } }); StreamString ss; - client.TestPacketSpeed(10, 32, 32, true, ss); + client.TestPacketSpeed(10, 32, 32, 4096, true, ss); client.Disconnect(); server_thread.join(); |