Skip to content

Commit fdb99fa

Browse files
committed
code format. round sumarry percentage to 2 places.
1 parent a7c29a6 commit fdb99fa

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

size_tools.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def measure_sizes():
121121
_changed_version_size = -1
122122
_changed_version_strings_size = -1
123123

124-
PERCENT_DIFF_FLAG_VALUE = 5.0 # percent change from current version to trigger comment
124+
PERCENT_DIFF_FLAG_VALUE = (
125+
5.0 # percent change from current version to trigger comment
126+
)
125127
BASELINE_FLAG_VALUE = 1500 # bytes or larger to trigger comment
126128
PERCENT_STRINGS_FLAG_VALUE = 50 # percent of mpy file(s) to trigger comment
127129

@@ -150,10 +152,14 @@ def measure_sizes():
150152
os.system(f"strings {mpy_file} > strings_output.txt")
151153
string_file_stats = os.stat("strings_output.txt")
152154
_changed_version_strings_size = string_file_stats.st_size
153-
_changed_version_strings_percentage = (string_file_stats.st_size / file_stats.st_size) * 100.0
155+
_changed_version_strings_percentage = (
156+
string_file_stats.st_size / file_stats.st_size
157+
) * 100.0
154158
output_str += f"strings output size: {_changed_version_strings_size} bytes\n"
155-
output_str += f"strings percentage of mpy: " \
156-
f"{_changed_version_strings_percentage:.2f}%\n"
159+
output_str += (
160+
f"strings percentage of mpy: "
161+
f"{_changed_version_strings_percentage:.2f}%\n"
162+
)
157163

158164
else:
159165
os.chdir(os.listdir("./")[0])
@@ -185,10 +191,13 @@ def measure_sizes():
185191
_cur_version_size = file_stats.st_size
186192
os.system(f"strings {mpy_file} > strings_output.txt")
187193
string_file_stats = os.stat("strings_output.txt")
188-
_cur_version_strings_percentage = (string_file_stats.st_size / file_stats.st_size) * 100.0
194+
_cur_version_strings_percentage = (
195+
string_file_stats.st_size / file_stats.st_size
196+
) * 100.0
189197
output_str += f"strings output size: {string_file_stats.st_size} bytes\n"
190-
output_str += f"strings percentage of mpy: " \
191-
f"{_cur_version_strings_percentage:.2f}%\n"
198+
output_str += (
199+
f"strings percentage of mpy: " f"{_cur_version_strings_percentage:.2f}%\n"
200+
)
192201
_cur_version_strings_size = string_file_stats.st_size
193202

194203
else:
@@ -201,7 +210,9 @@ def measure_sizes():
201210
output_str += f"total mpy files size: {file_size} bytes\n"
202211
output_str += f"strings output size: {strings_size} bytes\n"
203212
if file_size != 0:
204-
output_str += f"strings percentage of mpy: {_cur_version_strings_percentage:.2f}%\n"
213+
output_str += (
214+
f"strings percentage of mpy: {_cur_version_strings_percentage:.2f}%\n"
215+
)
205216

206217
"""
207218
output_str += "\n---\n\n"
@@ -239,9 +250,11 @@ def measure_sizes():
239250

240251
output_str += "\n---\n\n"
241252
output_str += "Summary:\n"
242-
output_str += f"Mpy File Size Difference: {_changed_version_size - _cur_version_size}\n"
253+
output_str += (
254+
f"Mpy File Size Difference: {_changed_version_size - _cur_version_size}\n"
255+
)
243256
output_str += f"Mpy Strings Size Difference: {_changed_version_strings_size - _cur_version_strings_size}\n"
244-
output_str += f"Mpy Strings Percentage Difference: {_changed_version_strings_percentage - _cur_version_strings_percentage}\n"
257+
output_str += f"Mpy Strings Percentage Difference: {_changed_version_strings_percentage - _cur_version_strings_percentage:.2f}%\n"
245258

246259
_is_changed_from_current = False
247260
_is_above_baseline = False
@@ -251,7 +264,9 @@ def measure_sizes():
251264
if _changed_version_size > BASELINE_FLAG_VALUE:
252265
_is_above_baseline = True
253266

254-
_changed_version_strings_percent = (_changed_version_strings_size / _changed_version_size) * 100.0
267+
_changed_version_strings_percent = (
268+
_changed_version_strings_size / _changed_version_size
269+
) * 100.0
255270
# print(f"{_changed_version_strings_percent} > {PERCENT_STRINGS_FLAG_VALUE}")
256271
if _changed_version_strings_percent > PERCENT_STRINGS_FLAG_VALUE:
257272
_is_over_string_percentage = True

0 commit comments

Comments
 (0)