From 6c554d45ccfaa4bb6783118c870336b3968f2bbc Mon Sep 17 00:00:00 2001 From: Justin Wai Date: Thu, 18 Jul 2024 19:20:37 +0800 Subject: [PATCH] Add profiling code with ifdef directives --- AT3/AT3Tags.cpp | 24 ++++++++++++++++++++++++ AT3/AT3Tags.hpp | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/AT3/AT3Tags.cpp b/AT3/AT3Tags.cpp index 79fefeb9..fedc1d46 100644 --- a/AT3/AT3Tags.cpp +++ b/AT3/AT3Tags.cpp @@ -8,6 +8,8 @@ #include #include +//#define PROFILING_PATH + using namespace EuroScopePlugIn; AT3Tags::AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR) : CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_PLUGIN_VERSION, MY_PLUGIN_DEVELOPER, MY_PLUGIN_COPYRIGHT) @@ -59,6 +61,17 @@ AT3Tags::AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR) : CPlugIn(E } } catch (...) {} //do nothing, other functions will catch it and return BAD DATA + +#ifdef PROFILING_PATH + profilingCSV.open(PROFILING_PATH); +#endif +} + +AT3Tags::~AT3Tags() +{ +#ifdef PROFILING_PATH + profilingCSV.close(); +#endif } string AT3Tags::GetActiveArrRwy(string airport) { @@ -172,6 +185,10 @@ void AT3Tags::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int bool isAT3Item = true; +#ifdef PROFILING_PATH + auto start = std::chrono::system_clock::now(); +#endif + *pColorCode = TAG_COLOR_RGB_DEFINED; switch (FlightPlan.GetState()) { case FLIGHT_PLAN_STATE_NON_CONCERNED: @@ -253,6 +270,13 @@ void AT3Tags::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int // Convert string output to character array if (isAT3Item) { strcpy_s(sItemString, 16, tagOutput.substr(0, 15).c_str()); + +#ifdef PROFILING_PATH + auto end = std::chrono::system_clock::now(); + auto elapsed = + std::chrono::duration_cast(end - start); + profilingCSV << ItemCode << "," << elapsed.count() << endl; +#endif } } diff --git a/AT3/AT3Tags.hpp b/AT3/AT3Tags.hpp index 347eba2d..1951b24a 100644 --- a/AT3/AT3Tags.hpp +++ b/AT3/AT3Tags.hpp @@ -11,6 +11,7 @@ #include "MAESTROapi.h" #include #include +#include using namespace std; using namespace EuroScopePlugIn; @@ -23,6 +24,8 @@ class AT3Tags : public: AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR); + ~AT3Tags(); + virtual void OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int ItemCode, @@ -95,4 +98,5 @@ class AT3Tags : COLORREF colorAssumed; COLORREF colorNotAssumed; COLORREF colorRedundant; + ofstream profilingCSV; };