Add performance metrics plot
This commit is contained in:
@@ -259,6 +259,7 @@ std::pair<xrt::drivers::wivrn::deserialization_packet, sockaddr_in6> xrt::driver
|
||||
if (received < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
|
||||
bytes_received_ += received;
|
||||
buffer.resize(received);
|
||||
|
||||
return {deserialization_packet{buffer}, addr};
|
||||
@@ -272,6 +273,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_ra
|
||||
if (received < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
|
||||
bytes_received_ += received;
|
||||
buffer.resize(received);
|
||||
|
||||
return deserialization_packet{buffer};
|
||||
@@ -279,8 +281,11 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_ra
|
||||
|
||||
void xrt::drivers::wivrn::UDP::send_raw(const std::vector<uint8_t> & data)
|
||||
{
|
||||
if (::send(fd, data.data(), data.size(), 0) < 0)
|
||||
ssize_t sent = ::send(fd, data.data(), data.size(), 0);
|
||||
if (sent < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
|
||||
bytes_sent_ += sent;
|
||||
}
|
||||
|
||||
void xrt::drivers::wivrn::UDP::send_raw(const std::vector<std::span<uint8_t>> & data)
|
||||
@@ -317,6 +322,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_ra
|
||||
if (received == 0)
|
||||
throw socket_shutdown{};
|
||||
|
||||
bytes_received_ += received;
|
||||
buffer.resize(already_received + received);
|
||||
|
||||
if (buffer.size() < 4)
|
||||
@@ -369,6 +375,8 @@ void xrt::drivers::wivrn::TCP::send_raw(const std::vector<std::span<uint8_t>> &
|
||||
if (sent < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
|
||||
bytes_sent_ += sent;
|
||||
|
||||
// iov fully consumed
|
||||
while (hdr.msg_iovlen > 0 and sent >= hdr.msg_iov[0].iov_len)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "wivrn_serialization.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -65,6 +66,9 @@ protected:
|
||||
int fd = -1;
|
||||
|
||||
fd_base(const fd_base &) = delete;
|
||||
std::atomic<uint64_t> bytes_sent_ = 0;
|
||||
std::atomic<uint64_t> bytes_received_ = 0;
|
||||
|
||||
public:
|
||||
fd_base() = default;
|
||||
fd_base(int fd): fd{fd} {}
|
||||
@@ -81,6 +85,16 @@ public:
|
||||
{
|
||||
return fd != -1;
|
||||
}
|
||||
|
||||
uint64_t bytes_sent() const
|
||||
{
|
||||
return bytes_sent_;
|
||||
}
|
||||
|
||||
uint64_t bytes_received() const
|
||||
{
|
||||
return bytes_received_;
|
||||
}
|
||||
};
|
||||
|
||||
class UDP : public fd_base
|
||||
|
||||
Reference in New Issue
Block a user