Changed int to int64_t in the profiler. Max time is now ~300 years.

This commit is contained in:
Jérôme 2019-04-26 11:18:43 +02:00
parent 6a13eb0c44
commit b6f1ad5573

View file

@ -236,7 +236,7 @@ class Profiler
{
protected:
std::string file_name; ///< File name to be displayed in the report.
int line_times[UTILS_PROFILER_NMAX]; ///< Line times in nanoseconds. The values are stored like so : line_times[__LINE__] = time_for_the_line.
int64_t line_times[UTILS_PROFILER_NMAX]; ///< Line times in nanoseconds. The values are stored like so : line_times[__LINE__] = time_for_the_line.
std::chrono::high_resolution_clock::time_point t0; ///< Time point storing the time when Reset() is called.
public:
@ -261,7 +261,7 @@ class Profiler
void DisplayData()
{
// compute sum of times
int sumOfTimes = 0;
int64_t sumOfTimes = 0;
for (size_t i = 0; i < UTILS_PROFILER_NMAX; i++) {
sumOfTimes += line_times[i];
}
@ -279,13 +279,13 @@ class Profiler
// Display the list sorted by descending line time
{
// convert the map to a vector of pairs...
std::vector<std::pair<int,int>> line_times_vec;
std::vector<std::pair<int,int64_t>> line_times_vec;
for (size_t i = 0; i < UTILS_PROFILER_NMAX; i++)
if(line_times[i] != 0)
line_times_vec.push_back(std::make_pair(i, line_times[i]));
// sort the vector of pairs
std::sort(line_times_vec.begin(), line_times_vec.end(), [](const std::pair<int,int> & a, const std::pair<int,int> & b) {
std::sort(line_times_vec.begin(), line_times_vec.end(), [](const std::pair<int,int64_t> & a, const std::pair<int,int64_t> & b) {
return a.second > b.second;// Descending order using the second entry of the pair
});