free and printFloatUS

changed destructor to function
removed creation of char array
This commit is contained in:
2023-07-05 17:03:09 +02:00
parent 1b70c89b01
commit 6dce34d1e6
3 changed files with 12 additions and 11 deletions

View File

@@ -44,7 +44,6 @@ public:
std::string printFloatUS(std::uint64_t ns)
{
char* str = new char[100];
std::uint64_t remainder = ns % 1000;
std::uint64_t front = ns / 1000;
char strRemainder[4];
@@ -56,9 +55,7 @@ std::string printFloatUS(std::uint64_t ns)
}
strRemainder[3] = '\0';
sprintf(str, "%lu.%s", front, strRemainder);
std::string message(str);
std::string message = std::to_string(front) + "." + strRemainder;
return message;
}
@@ -350,15 +347,16 @@ void TaskingProfiler::saveProfile()
}
//Destructor
TaskingProfiler::~TaskingProfiler()
void TaskingProfiler::free()
{
std::uint16_t total_cores = TaskingProfiler::getInstance().getTotalCores();
for(std::uint16_t cpu_id = 0; cpu_id < total_cores; cpu_id++)
{
delete[] task_data[cpu_id];
}
delete[] task_data;
delete[] task_id_counter;
delete[] queue_id_counter;
delete[] TaskingProfiler::getInstance().getTaskIdCounter();
delete[] TaskingProfiler::getInstance().getQueueIdCounter();
}

View File

@@ -28,9 +28,6 @@ public:
std::chrono::high_resolution_clock::time_point timestamp;
};
//Destructor
~TaskingProfiler();
private:
TaskingProfiler() {};
std::chrono::time_point<std::chrono::high_resolution_clock> relTime;
@@ -97,7 +94,13 @@ public:
*/
void printTP(std::uint64_t start, std::uint64_t end);
void free();
task_info** getTaskData() { return task_data; }
queue_info** getQueueData() { return queue_data; }
std::uint64_t* getTaskIdCounter() { return task_id_counter; }
std::uint64_t* getQueueIdCounter() { return queue_id_counter; }
std::uint16_t getTotalCores() { return total_cores; }
std::chrono::time_point<std::chrono::high_resolution_clock> getTinit() { return tinit; }
};

View File

@@ -276,7 +276,7 @@ public:
~runtime_guard() noexcept { runtime::start_and_wait();
if constexpr (config::use_tasking_profiler())
{
TaskingProfiler::getInstance().~TaskingProfiler();
TaskingProfiler::getInstance().free();
}
}
};