diff --git a/src/c++/hashtable.cpp b/src/c++/hashtable.cpp index a9f8262e..1d3b32e2 100644 --- a/src/c++/hashtable.cpp +++ b/src/c++/hashtable.cpp @@ -86,6 +86,12 @@ void HashTable::add_child_time(size_t hash, time_duration_t time_delta) entry.child_walltime_ += time_delta; } +long double HashTable::seconds(time_duration_t input_dur) const +{ + long double n = 1.0e-9; + return static_cast(input_dur.count())*n; +} + /** * @brief Writes all entries in the hashtable, sorted according to self times. * @@ -125,10 +131,10 @@ void HashTable::write() // Data entries for (auto& [hash, entry] : hashvec) { std::cout - << std::setw(40) << std::left << entry.region_name_ << " " - << std::setw(15) << std::right << entry.self_walltime_.count() << " " - << std::setw(15) << std::right << entry.total_walltime_.count() << " " - << std::setw(10) << std::right << entry.call_count_ << "\n"; + << std::setw(40) << std::left << entry.region_name_ << " " + << std::setw(15) << std::right << seconds(entry.self_walltime_) << " " + << std::setw(15) << std::right << seconds(entry.total_walltime_) << " " + << std::setw(10) << std::right << entry.call_count_ << "\n"; } } @@ -164,9 +170,9 @@ std::vector HashTable::list_keys() * */ -double HashTable::get_total_walltime(size_t const hash) const +long double HashTable::get_total_walltime(size_t const hash) const { - return table_.at(hash).total_walltime_.count(); + return seconds(table_.at(hash).total_walltime_); } /** @@ -174,10 +180,10 @@ double HashTable::get_total_walltime(size_t const hash) const * */ -double HashTable::get_self_walltime(size_t const hash) +long double HashTable::get_self_walltime(size_t const hash) { this->compute_self_times(); - return table_.at(hash).self_walltime_.count(); + return seconds(table_.at(hash).self_walltime_); } /** @@ -185,9 +191,9 @@ double HashTable::get_self_walltime(size_t const hash) * */ -double HashTable::get_child_walltime(size_t const hash) const +long double HashTable::get_child_walltime(size_t const hash) const { - return table_.at(hash).child_walltime_.count(); + return seconds(table_.at(hash).child_walltime_); } /** diff --git a/src/c++/hashtable.h b/src/c++/hashtable.h index f57c979e..a05dca1d 100644 --- a/src/c++/hashtable.h +++ b/src/c++/hashtable.h @@ -31,7 +31,7 @@ #include // Type definitions for chrono steady clock time points and durations -using time_duration_t = std::chrono::duration; +using time_duration_t = std::chrono::duration; using time_point_t = std::chrono::time_point; @@ -76,6 +76,9 @@ class HashTable{ std::hash hash_function_; std::vector> hashvec; + // Prototype.. TODO Think about if this is needed, and where to place it + long double seconds(time_duration_t input_dur) const; + public: // Constructors @@ -93,9 +96,9 @@ class HashTable{ void compute_self_times(); // Getters - double get_total_walltime(size_t const hash) const; - double get_self_walltime(size_t const hash); - double get_child_walltime(size_t const hash) const; + long double get_total_walltime(size_t const hash) const; + long double get_self_walltime(size_t const hash); + long double get_child_walltime(size_t const hash) const; std::string const& get_region_name(size_t const hash) const; unsigned long long int const& get_region_call_count(size_t const hash) const; diff --git a/src/c++/profiler.cpp b/src/c++/profiler.cpp index 9ea7f317..84a7c74f 100644 --- a/src/c++/profiler.cpp +++ b/src/c++/profiler.cpp @@ -137,7 +137,7 @@ void Profiler::write() * */ -double Profiler::get_thread0_walltime(size_t const hash) const +long double Profiler::get_thread0_walltime(size_t const hash) const { auto tid = static_cast(0); return thread_hashtables_[tid].get_total_walltime(hash); @@ -148,7 +148,7 @@ double Profiler::get_thread0_walltime(size_t const hash) const * */ -double Profiler::get_self_walltime(size_t const hash, int const input_tid) +long double Profiler::get_self_walltime(size_t const hash, int const input_tid) { auto tid = static_cast(input_tid); return thread_hashtables_[tid].get_self_walltime(hash); @@ -159,7 +159,7 @@ double Profiler::get_self_walltime(size_t const hash, int const input_tid) * */ -double Profiler::get_child_walltime(size_t const hash, int const input_tid) const +long double Profiler::get_child_walltime(size_t const hash, int const input_tid) const { auto tid = static_cast(input_tid); return thread_hashtables_[tid].get_child_walltime(hash); diff --git a/src/c++/profiler.h b/src/c++/profiler.h index dc4891a9..23c5f365 100644 --- a/src/c++/profiler.h +++ b/src/c++/profiler.h @@ -57,9 +57,9 @@ class Profiler void write(); // HashEntry getters - double get_thread0_walltime(size_t const hash) const; - double get_self_walltime(size_t const hash, int const input_tid); - double get_child_walltime(size_t const hash, int const input_tid) const; + long double get_thread0_walltime(size_t const hash) const; + long double get_self_walltime(size_t const hash, int const input_tid); + long double get_child_walltime(size_t const hash, int const input_tid) const; std::string get_region_name(size_t const hash, int const input_tid) const; unsigned long long int get_region_call_count(size_t const hash, int const input_tid) const;