Compare commits

..

2 Commits

Author SHA1 Message Date
Green Sky
96b20aab67
update sdl again (we are not past rc1)
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
2025-01-20 15:42:59 +01:00
Green Sky
ca59e51e9e
netprof udp byte averages 2025-01-20 15:42:34 +01:00
5 changed files with 52 additions and 12 deletions

View File

@ -32,7 +32,8 @@ if (NOT TARGET SDL3::SDL3)
#GIT_TAG f8f8d87bfaf3d8557a5c13e0072964a537569b6c # tip 02-01-2025 - android cam fix
#GIT_TAG 22422f7748d5128135995ed34c8f8012861c7332 # tip 07-01-2025 (3.1.8)
#GIT_TAG 191a6417d581b79cab5698dee84554ea64b5ac61 # tip 14-01-2025 - hotplug asan crash fix
GIT_TAG 355f69ebfe7a5f44a28e10569589a1d300aad2b5 # tip 15-01-2024 - more recent for continous tray testing
#GIT_TAG 355f69ebfe7a5f44a28e10569589a1d300aad2b5 # tip 15-01-2024 - more recent for continous tray testing
GIT_TAG 90b2e2527eeb6614cedd15f61062f62680252be6 # tip 20-01-2024 - tray supposetly fixed
FIND_PACKAGE_ARGS # for the future
)

8
flake.lock generated
View File

@ -63,17 +63,17 @@
"sdl3": {
"flake": false,
"locked": {
"lastModified": 1736977543,
"narHash": "sha256-+IqnMZl3GFsgi5O94XjtYDzU6swjVLPducJExi3ZUd4=",
"lastModified": 1737355177,
"narHash": "sha256-LYo0m0rFpFYrZZERV5LGuXxIo0mjqIiZT+UjQojIgvc=",
"owner": "libsdl-org",
"repo": "SDL",
"rev": "355f69ebfe7a5f44a28e10569589a1d300aad2b5",
"rev": "90b2e2527eeb6614cedd15f61062f62680252be6",
"type": "github"
},
"original": {
"owner": "libsdl-org",
"repo": "SDL",
"rev": "355f69ebfe7a5f44a28e10569589a1d300aad2b5",
"rev": "90b2e2527eeb6614cedd15f61062f62680252be6",
"type": "github"
}
},

View File

@ -13,7 +13,7 @@
flake = false;
};
sdl3 = {
url = "github:libsdl-org/SDL/355f69ebfe7a5f44a28e10569589a1d300aad2b5"; # keep in sync with cmake
url = "github:libsdl-org/SDL/90b2e2527eeb6614cedd15f61062f62680252be6"; # keep in sync with cmake
flake = false;
};
sdl3_image = {

View File

@ -1,6 +1,7 @@
#include "./tox_netprof_ui.hpp"
#include <imgui/imgui.h>
#include <string>
static const char* typedPkgIDToString(Tox_Netprof_Packet_Type type, uint8_t id) {
// pain
@ -69,7 +70,11 @@ void ToxNetprofUI::tick(float time_delta) {
_time_since_last_add += time_delta;
if (_time_since_last_add >= _value_add_interval) {
_time_since_last_add = 0.f; // very loose
if (_time_since_last_add >= 20.f * _value_add_interval) {
_time_since_last_add = 0.f; // cut our losses
} else {
_time_since_last_add -= _value_add_interval;
}
if (_udp_tctx.empty()) {
_udp_tctx.push_back(0.f);
@ -107,9 +112,6 @@ void ToxNetprofUI::tick(float time_delta) {
_udp_tbrx_prev = new_value;
}
if (_udp_tbrx.empty()) {
}
// TODO: limit
while (_udp_tctx.size() > 5*60) {
_udp_tctx.erase(_udp_tctx.begin());
@ -126,6 +128,22 @@ void ToxNetprofUI::tick(float time_delta) {
while (_udp_tbrx.size() > 5*60) {
_udp_tbrx.erase(_udp_tbrx.begin());
}
_udp_tbtx_avg = 0.f;
if (!_udp_tbtx.empty()) {
for (const auto bytes : _udp_tbtx) {
_udp_tbtx_avg += bytes;
}
_udp_tbtx_avg /= (_udp_tbtx.size() * _value_add_interval);
}
_udp_tbrx_avg = 0.f;
if (!_udp_tbrx.empty()) {
for (const auto bytes : _udp_tbrx) {
_udp_tbrx_avg += bytes;
}
_udp_tbrx_avg /= (_udp_tbrx.size() * _value_add_interval);
}
}
}
@ -290,8 +308,26 @@ float ToxNetprofUI::render(float time_delta) {
const float line_height = ImGui::GetTextLineHeight();
ImGui::PlotHistogram("udp total packets sent##histograms", _udp_tctx.data(), _udp_tctx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
ImGui::PlotHistogram("udp total packets received##histograms", _udp_tcrx.data(), _udp_tcrx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
ImGui::PlotHistogram("udp total bytes sent##histograms", _udp_tbtx.data(), _udp_tbtx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
ImGui::PlotHistogram("udp total bytes received##histograms", _udp_tbrx.data(), _udp_tbrx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
std::string udp_tbtx_avg_str {"avg " + std::to_string(_udp_tbtx_avg) + " B/s"};
ImGui::PlotHistogram(
"udp total bytes sent##histograms",
_udp_tbtx.data(), _udp_tbtx.size(),
0,
udp_tbtx_avg_str.c_str(),
0.f, FLT_MAX,
{0, 3*line_height}
);
std::string udp_tbrx_avg_str {"avg " + std::to_string(_udp_tbrx_avg) + " B/s"};
ImGui::PlotHistogram(
"udp total bytes received##histograms",
_udp_tbrx.data(), _udp_tbrx.size(),
0,
udp_tbrx_avg_str.c_str(),
0.f, FLT_MAX,
{0, 3*line_height}
);
} else {
ImGui::TextUnformatted("logging disabled!");
if (ImGui::Button("enable")) {

View File

@ -43,6 +43,9 @@ class ToxNetprofUI {
std::vector<float> _udp_tbtx;
std::vector<float> _udp_tbrx;
float _udp_tbtx_avg {0.f};
float _udp_tbrx_avg {0.f};
const float _value_add_interval {1.f}; // every second
float _time_since_last_add {0.f};