From 93ff4a8cb6356478491f77219c435d83747ae9ab Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Fri, 12 May 2023 11:49:28 +0000 Subject: [PATCH] Fix windows build for profiler and add profiler logging --- include/ftl/profiler.hpp | 6 ++++++ src/ctpl_stl.cpp | 1 + src/streams/netstream.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/ftl/profiler.hpp b/include/ftl/profiler.hpp index 8b6afbb..1e48b0a 100644 --- a/include/ftl/profiler.hpp +++ b/include/ftl/profiler.hpp @@ -38,3 +38,9 @@ #define FTL_Profile(LABEL, LIMIT) {} #endif + +inline void FTL_PROFILE_LOG(const std::string& message) { +#ifdef TRACY_ENABLE + TracyMessage(message.c_str(), message.size()); +#endif +} \ No newline at end of file diff --git a/src/ctpl_stl.cpp b/src/ctpl_stl.cpp index 7d4e8f9..b82a72a 100644 --- a/src/ctpl_stl.cpp +++ b/src/ctpl_stl.cpp @@ -1,6 +1,7 @@ #ifdef WIN32 #include <Ws2tcpip.h> #include <windows.h> +#include <string> #endif #include <ftl/lib/ctpl_stl.hpp> diff --git a/src/streams/netstream.cpp b/src/streams/netstream.cpp index 36e4470..9b0228f 100644 --- a/src/streams/netstream.cpp +++ b/src/streams/netstream.cpp @@ -14,6 +14,7 @@ #include "netstream.hpp" #include <ftl/time.hpp> #include <ftl/counter.hpp> +#include <ftl/profiler.hpp> #include "../uuidMSGPACK.hpp" #include "packetMsgpack.hpp" @@ -327,7 +328,7 @@ void Net::_run() { state->base_pkt_ts_ = raw_ats; cts = 0; } - ats = raw_ats - state->base_pkt_ts_ + buffering_; + ats = raw_ats - state->base_pkt_ts_ + buffering_; } else { // LOG(WARNING) << "No packets to present: " << cts; continue; @@ -366,10 +367,12 @@ void Net::_run() { } ftl::pool.push([ - this, + this, c = std::move(ftl::Counter(&state->active)), c2 = std::move(ftl::Counter(&jobs_)), framePackets](int ix) { + + FTL_PROFILE_SCOPE("ProcessFramePackets"); for (auto buf : framePackets) { StreamPacket *spkt; DataPacket *pkt; -- GitLab