|
14 | 14 | import cloudpickle |
15 | 15 | from datetime import timezone, timedelta |
16 | 16 | import pytz |
17 | | -from src.utils import floor_decimal |
| 17 | +from src.utils import floor_decimal, get_unit_and_scale_by_max_file_size_mb |
| 18 | + |
18 | 19 |
|
19 | 20 | def count_lines(file_name): |
20 | 21 | if platform.system() in ["Linux", "Darwin"]: # Linux or macOS |
@@ -109,9 +110,7 @@ def set_time_zone(self): |
109 | 110 | if "listening on port" in line: |
110 | 111 | parts = line.strip().split() |
111 | 112 | mgr_start_datestring = f"{parts[0]} {parts[1]}" |
112 | | - mgr_start_datestring = datetime.strptime( |
113 | | - mgr_start_datestring, "%Y/%m/%d %H:%M:%S.%f" |
114 | | - ).replace(microsecond=0) |
| 113 | + mgr_start_datestring = datetime.strptime(mgr_start_datestring, "%Y/%m/%d %H:%M:%S.%f").replace(microsecond=0) |
115 | 114 | break |
116 | 115 |
|
117 | 116 | # read the first line containing "MANAGER" and "START" in transactions file |
@@ -152,8 +151,7 @@ def set_time_zone(self): |
152 | 151 |
|
153 | 152 | @lru_cache(maxsize=4096) |
154 | 153 | def datestring_to_timestamp(self, datestring): |
155 | | - equivalent_datestring = datetime.strptime( |
156 | | - datestring, "%Y/%m/%d %H:%M:%S.%f").replace(tzinfo=self.manager.equivalent_tz) |
| 154 | + equivalent_datestring = datetime.strptime(datestring, "%Y/%m/%d %H:%M:%S.%f").replace(tzinfo=self.manager.equivalent_tz) |
157 | 155 | unix_timestamp = float(equivalent_datestring.timestamp()) |
158 | 156 | return unix_timestamp |
159 | 157 |
|
@@ -757,7 +755,10 @@ def parse_debug(self): |
757 | 755 |
|
758 | 756 | self.current_try_id = defaultdict(int) |
759 | 757 | total_lines = count_lines(self.debug) |
| 758 | + debug_file_size_mb = floor_decimal(os.path.getsize(self.debug) / 1024 / 1024, 2) |
| 759 | + unit, scale = get_unit_and_scale_by_max_file_size_mb(debug_file_size_mb) |
760 | 760 |
|
| 761 | + print(f"Debug file size: {floor_decimal(debug_file_size_mb * scale, 2)} {unit}") |
761 | 762 | with open(self.debug, 'rb') as file: |
762 | 763 | pbar = tqdm(total=total_lines, desc="Parsing debug") |
763 | 764 | for raw_line in file: |
|
0 commit comments