File tree Expand file tree Collapse file tree 3 files changed +13
-42
lines changed
Expand file tree Collapse file tree 3 files changed +13
-42
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,9 @@ int main(int argc, char *argv[])
117117
118118 // Processing: In this phase the input file(s) are read and parsed,
119119 // populating some of the tables.
120- progress_display_t progress;
121-
122120 util::timer_t timer_parse;
123121
124- progress. update ( osmdata.process_files (files, options.bbox ) );
122+ auto const progress = osmdata.process_files (files, options.bbox );
125123
126124 progress.print_status (std::time (nullptr ));
127125 fmt::print (stderr, " parse time: {}\n " ,
Original file line number Diff line number Diff line change 22#include " logging.hpp"
33#include " progress-display.hpp"
44
5- void progress_display_t::update (progress_display_t const &other) noexcept
6- {
7- m_node += other.m_node ;
8- m_way += other.m_way ;
9- m_rel += other.m_rel ;
10- }
11-
125void progress_display_t::print_summary () const
136{
147 std::time_t const now = std::time (nullptr );
Original file line number Diff line number Diff line change @@ -21,72 +21,52 @@ class progress_display_t
2121{
2222 struct Counter
2323 {
24- osmid_t count = 0 ;
24+ std:: size_t count = 0 ;
2525 osmid_t max = 0 ;
2626 std::time_t start = 0 ;
27- int m_frac;
28-
29- explicit Counter (int frac) noexcept : m_frac(frac) {}
3027
3128 osmid_t count_k () const noexcept { return count / 1000 ; }
3229
33- bool add (osmid_t id) noexcept
30+ std:: size_t add (osmid_t id) noexcept
3431 {
35- if (id > max) {
36- max = id;
37- }
32+ max = id;
3833 if (count == 0 ) {
3934 start = std::time (nullptr );
4035 }
41- ++count;
42-
43- return count % m_frac == 0 ;
44- }
45-
46- Counter &operator +=(Counter const &rhs) noexcept
47- {
48- count += rhs.count ;
49- if (rhs.max > max) {
50- max = rhs.max ;
51- }
52- if (start == 0 ) {
53- start = rhs.start ;
54- }
55-
56- return *this ;
36+ return ++count;
5737 }
5838 };
5939
6040public:
6141 progress_display_t () noexcept : m_last_print_time(std::time(nullptr )) {}
6242
63- void update (progress_display_t const &other) noexcept ;
6443 void print_summary () const ;
6544 void print_status (std::time_t now) const ;
66- void possibly_print_status ();
6745
6846 void add_node (osmid_t id)
6947 {
70- if (m_node.add (id)) {
48+ if (m_node.add (id) % 10000 == 0 ) {
7149 possibly_print_status ();
7250 }
7351 }
7452
7553 void add_way (osmid_t id)
7654 {
77- if (m_way.add (id)) {
55+ if (m_way.add (id) % 1000 == 0 ) {
7856 possibly_print_status ();
7957 }
8058 }
8159
8260 void add_rel (osmid_t id)
8361 {
84- if (m_rel.add (id)) {
62+ if (m_rel.add (id) % 10 == 0 ) {
8563 possibly_print_status ();
8664 }
8765 }
8866
8967private:
68+ void possibly_print_status ();
69+
9070 static double count_per_second (osmid_t count, uint64_t elapsed) noexcept
9171 {
9272 if (count == 0 ) {
@@ -124,9 +104,9 @@ class progress_display_t
124104 return now - m_rel.start ;
125105 }
126106
127- Counter m_node{10000 };
128- Counter m_way{1000 };
129- Counter m_rel{10 };
107+ Counter m_node{};
108+ Counter m_way{};
109+ Counter m_rel{};
130110 std::time_t m_last_print_time;
131111};
132112
You can’t perform that action at this time.
0 commit comments