Compare commits

..

No commits in common. "96b20aab67047cd27d8851e70a987c001c33c4ff" and "d416d3d5951f027abbedc15922a6648589a98e90" have entirely different histories.

5 changed files with 12 additions and 52 deletions

View File

@ -32,8 +32,7 @@ if (NOT TARGET SDL3::SDL3)
#GIT_TAG f8f8d87bfaf3d8557a5c13e0072964a537569b6c # tip 02-01-2025 - android cam fix #GIT_TAG f8f8d87bfaf3d8557a5c13e0072964a537569b6c # tip 02-01-2025 - android cam fix
#GIT_TAG 22422f7748d5128135995ed34c8f8012861c7332 # tip 07-01-2025 (3.1.8) #GIT_TAG 22422f7748d5128135995ed34c8f8012861c7332 # tip 07-01-2025 (3.1.8)
#GIT_TAG 191a6417d581b79cab5698dee84554ea64b5ac61 # tip 14-01-2025 - hotplug asan crash fix #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 FIND_PACKAGE_ARGS # for the future
) )

8
flake.lock generated
View File

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

View File

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

View File

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

View File

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