Skip to content

Commit

Permalink
Add profiling code with ifdef directives
Browse files Browse the repository at this point in the history
  • Loading branch information
EightSmart committed Jul 18, 2024
1 parent c4f42d6 commit 6c554d4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions AT3/AT3Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <chrono>
#include <ctime>

//#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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<std::chrono::nanoseconds>(end - start);
profilingCSV << ItemCode << "," << elapsed.count() << endl;
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions AT3/AT3Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "MAESTROapi.h"
#include <chrono>
#include <ctime>
#include <fstream>

using namespace std;
using namespace EuroScopePlugIn;
Expand All @@ -23,6 +24,8 @@ class AT3Tags :
public:
AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR);

~AT3Tags();

virtual void OnGetTagItem(CFlightPlan FlightPlan,
CRadarTarget RadarTarget,
int ItemCode,
Expand Down Expand Up @@ -95,4 +98,5 @@ class AT3Tags :
COLORREF colorAssumed;
COLORREF colorNotAssumed;
COLORREF colorRedundant;
ofstream profilingCSV;
};

0 comments on commit 6c554d4

Please sign in to comment.