aboutsummaryrefslogtreecommitdiff
path: root/scripts/code_size_compare.py
diff options
context:
space:
mode:
authorYanray Wang <yanray.wang@arm.com>2023-07-25 10:37:11 +0800
committerYanray Wang <yanray.wang@arm.com>2023-07-25 10:37:12 +0800
commite4a3636fac45317323c4132450368f824a945d27 (patch)
tree24717a6050b4bdc9c16c24f3f0bd07450b32c875 /scripts/code_size_compare.py
parent25bd33189927a2741124afb45fb719e3e87ecce3 (diff)
downloadmbedtls-e4a3636fac45317323c4132450368f824a945d27.zip
mbedtls-e4a3636fac45317323c4132450368f824a945d27.tar.gz
mbedtls-e4a3636fac45317323c4132450368f824a945d27.tar.bz2
code_size_compare: add comments to make code more readable
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
Diffstat (limited to 'scripts/code_size_compare.py')
-rwxr-xr-xscripts/code_size_compare.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py
index 88578fe..0c29c41 100755
--- a/scripts/code_size_compare.py
+++ b/scripts/code_size_compare.py
@@ -92,8 +92,9 @@ class CodeSizeDistinctInfo: # pylint: disable=too-few-public-methods
def get_info_indication(self):
"""Return a unique string to indicate Code Size Distinct Information."""
- return '{}-{}-{}-{}'\
- .format(self.git_rev, self.arch, self.config, self.compiler)
+ return '{rev}-{arch}-{config}-{cc}'\
+ .format(rev=self.git_rev, arch=self.arch, config=self.config,
+ cc=self.compiler)
class CodeSizeCommonInfo: # pylint: disable=too-few-public-methods
@@ -112,8 +113,8 @@ class CodeSizeCommonInfo: # pylint: disable=too-few-public-methods
def get_info_indication(self):
"""Return a unique string to indicate Code Size Common Information."""
- return '{}'\
- .format(self.measure_cmd.strip().split(' ')[0])
+ return '{measure_tool}'\
+ .format(measure_tool=self.measure_cmd.strip().split(' ')[0])
class CodeSizeResultInfo: # pylint: disable=too-few-public-methods
"""Data structure to store result options for code size comparison."""
@@ -223,11 +224,11 @@ class CodeSizeBuildInfo: # pylint: disable=too-few-public-methods
"""Infer command to set up proper configuration before running make."""
pre_make_cmd = [] #type: typing.List[str]
if self.config == SupportedConfig.TFM_MEDIUM.value:
- pre_make_cmd.append('cp -r {} {}'
- .format(TFM_MEDIUM_CONFIG_H, CONFIG_H))
- pre_make_cmd.append('cp -r {} {}'
- .format(TFM_MEDIUM_CRYPTO_CONFIG_H,
- CRYPTO_CONFIG_H))
+ pre_make_cmd.append('cp -r {src} {dest}'
+ .format(src=TFM_MEDIUM_CONFIG_H, dest=CONFIG_H))
+ pre_make_cmd.append('cp -r {src} {dest}'
+ .format(src=TFM_MEDIUM_CRYPTO_CONFIG_H,
+ dest=CRYPTO_CONFIG_H))
return pre_make_cmd
@@ -641,15 +642,20 @@ class CodeSizeGeneratorWithSize(CodeSizeGenerator):
output.write(
format_string
.format(fname,
+ # current(text,data)
str(text_vari[0]) + "," + str(data_vari[0]),
+ # old(text,data)
str(text_vari[1]) + "," + str(data_vari[1]),
+ # change(text,data)
str(text_vari[2]) + "," + str(data_vari[2]),
+ # change%(text,data)
"{:.0%}".format(text_vari[3]) + ","
+ "{:.0%}".format(data_vari[3])))
else:
output.write(
format_string
.format(fname,
+ # current(text,data)
str(text_vari[0]) + "," + str(data_vari[0]),
'None', 'None', 'None'))