-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display preprocessing duration in logs in human-readable format…
… (not in microseconds) #296
- Loading branch information
1 parent
733b5f9
commit a2499af
Showing
4 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "silo/common/block_timer.h" | ||
|
||
#include <chrono> | ||
#include <iomanip> | ||
#include <string> | ||
|
||
namespace silo::common { | ||
|
||
std::string formatDuration(int64_t int_microseconds) { | ||
auto microseconds = std::chrono::microseconds(int_microseconds); | ||
auto hours = std::chrono::duration_cast<std::chrono::hours>(microseconds); | ||
microseconds -= hours; | ||
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(microseconds); | ||
microseconds -= minutes; | ||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(microseconds); | ||
microseconds -= seconds; | ||
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(microseconds); | ||
|
||
std::stringstream string_stream; | ||
|
||
string_stream << std::setw(2) << std::setfill('0') << hours.count() << ":"; | ||
string_stream << std::setw(2) << std::setfill('0') << minutes.count() << ":"; | ||
string_stream << std::setw(2) << std::setfill('0') << seconds.count() << "."; | ||
string_stream << std::setw(3) << std::setfill('0') << milliseconds.count(); | ||
|
||
return string_stream.str(); | ||
} | ||
|
||
} // namespace silo::common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters