Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
- like you wrote by yourself :-) #225 (comment)
- plus removing all the calls of start_wall_time throughout the files
- log_duration is only called once so cutting down the method makes it clearer and identical to stop_and_return in my opinion
- plus painting a "line" before the logging to be cosistent to the other parts of the log
  • Loading branch information
treee111 committed Nov 5, 2023
1 parent b29bf35 commit ff54dac
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion wahoomc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def run(run_level):
o_osm_data = XYOsmData(o_input_data)

timings = Timings()
timings.start_wall_time()
# Check for not existing or expired files. Mark for download, if dl is needed
o_osm_data.process_input_of_the_tool()
o_downloader = o_osm_data.get_downloader()
Expand Down
4 changes: 0 additions & 4 deletions wahoomc/osm_maps_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def filter_tags_from_country_osm_pbf_files(self): # pylint: disable=too-many-st
log.info('# Filter tags from country osm.pbf files')

timings = Timings()
timings.start_wall_time()
for key, val in self.o_osm_data.border_countries.items():
# evaluate contry directory, create if not exists
country_dir = os.path.join(USER_OUTPUT_DIR, key)
Expand Down Expand Up @@ -593,7 +592,6 @@ def split_filtered_country_files_to_tiles(self):
log.info('-' * 80)
log.info('# Split filtered country files to tiles')
timings = Timings()
timings.start_wall_time()
tile_count = 1
for tile in self.o_osm_data.tiles:

Expand All @@ -602,7 +600,6 @@ def split_filtered_country_files_to_tiles(self):
continue
self.log_tile(tile["x"], tile["y"], tile_count, country)
timings_tile = Timings()
timings_tile.start_wall_time()
out_file = os.path.join(USER_OUTPUT_DIR,
f'{tile["x"]}', f'{tile["y"]}', f'split-{country}.osm.pbf')
out_file_names = os.path.join(USER_OUTPUT_DIR,
Expand Down Expand Up @@ -784,7 +781,6 @@ def create_map_files(self, save_cruiser, tag_wahoo_xml):
threads = 1

timings = Timings()
timings.start_wall_time()
tile_count = 1
for tile in self.o_osm_data.tiles:
self.log_tile(tile["x"], tile["y"], tile_count)
Expand Down
3 changes: 2 additions & 1 deletion wahoomc/timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Timings:
wall_time_start = None
wall_time_end = None

def start_wall_time(self):
def __init__(self):
"""Start the wall time"""
self.wall_time_start = time.perf_counter()

Expand All @@ -31,6 +31,7 @@ def stop_and_return(self, additional_info='') -> str:
def stop_and_log(self, additional_info=''):
"""Log the time taken"""
self.stop_wall_time()
log.info('-' * 80)
self.log_duration(additional_info)

def log_duration(self,additional_info=''):
Expand Down

0 comments on commit ff54dac

Please sign in to comment.