11#include " format.hpp"
22#include " logging.hpp"
33#include " progress-display.hpp"
4-
5- void progress_display_t::print_summary () const
6- {
7- std::time_t const now = std::time (nullptr );
8-
9- log_info (" Node stats: total({}), max({}) in {}s" , m_node.count , m_node.max ,
10- nodes_time (now));
11- log_info (" Way stats: total({}), max({}) in {}s" , m_way.count , m_way.max ,
12- ways_time (now));
13- log_info (" Relation stats: total({}), max({}) in {}s" , m_rel.count ,
14- m_rel.max , rels_time (now));
15- }
4+ #include " util.hpp"
165
176static double count_per_second (osmid_t count, uint64_t elapsed) noexcept
187{
@@ -27,6 +16,40 @@ static double count_per_second(osmid_t count, uint64_t elapsed) noexcept
2716 return static_cast <double >(count) / elapsed;
2817}
2918
19+ static std::string cps_display (osmid_t count, uint64_t elapsed) noexcept
20+ {
21+ double const cps = count_per_second (count, elapsed);
22+
23+ if (cps >= 1000.0 ) {
24+ return " {:.0f}k/s" _format (cps / 1000 );
25+ }
26+ return " {:.0f}/s" _format (cps);
27+ }
28+
29+ void progress_display_t::print_summary () const
30+ {
31+ std::time_t const now = std::time (nullptr );
32+
33+ if (m_enabled) {
34+ fmt::print (stderr, " \r {:78s}\r " , " " );
35+ }
36+
37+ log_info (" Reading input files done in {}." ,
38+ util::human_readable_duration (overall_time (now)));
39+
40+ auto const nt = nodes_time (now);
41+ log_info (" Processed {} nodes in {} - {}" , m_node.count ,
42+ util::human_readable_duration (nt), cps_display (m_node.count , nt));
43+
44+ auto const wt = ways_time (now);
45+ log_info (" Processed {} ways in {} - {}" , m_way.count ,
46+ util::human_readable_duration (wt), cps_display (m_way.count , wt));
47+
48+ auto const rt = rels_time (now);
49+ log_info (" Processed {} relations in {} - {}" , m_rel.count ,
50+ util::human_readable_duration (rt), cps_display (m_rel.count , rt));
51+ }
52+
3053void progress_display_t::print_status (std::time_t now) const
3154{
3255 if (m_enabled) {
@@ -50,3 +73,33 @@ void progress_display_t::possibly_print_status()
5073 print_status (now);
5174 }
5275}
76+
77+ uint64_t progress_display_t::nodes_time (std::time_t now) const noexcept
78+ {
79+ if (m_node.count == 0 ) {
80+ return 0 ;
81+ }
82+ return (m_way.start > 0 ? m_way.start : now) - m_node.start ;
83+ }
84+
85+ uint64_t progress_display_t::ways_time (std::time_t now) const noexcept
86+ {
87+ if (m_way.count == 0 ) {
88+ return 0 ;
89+ }
90+ return (m_rel.start > 0 ? m_rel.start : now) - m_way.start ;
91+ }
92+
93+ uint64_t progress_display_t::rels_time (std::time_t now) const noexcept
94+ {
95+ if (m_rel.count == 0 ) {
96+ return 0 ;
97+ }
98+ return now - m_rel.start ;
99+ }
100+
101+ uint64_t progress_display_t::overall_time (std::time_t now) const noexcept
102+ {
103+ return now - m_node.start ;
104+ }
105+
0 commit comments