[SWDEV-496639] Align amd-smi xgmi statistics

The xgmi read and write values were displayed in KB. The numbers became
unreadable due to misalignment. So, converted read and write values to
readable units using helper function. Updated Changelog.

Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
Change-Id: I4c90a1de8a58c29cbdf43fe3480a1546f3946673
This commit is contained in:
Bindhiya Kanangot Balakrishnan authored and Maisam Arif committed 2024-12-09 12:57:45 -05:00
1 parent d323ecff97
commit 288b11df37
3 files changed
+36 -6

No files matched your search

+4 -4
Vedi File
@@ -5298,8 +5298,8 @@ class AMDSMICommands():
data_unit = 'KB'
if self.logger.is_human_readable_format():
dest_link_dict['read'] = f"{read} {data_unit}"
dest_link_dict['write'] = f"{write} {data_unit}"
dest_link_dict['read'] = self.helpers.convert_bytes_to_readable(read * 1024, True)
dest_link_dict['write'] = self.helpers.convert_bytes_to_readable(write * 1024, True)
elif self.logger.is_json_format():
dest_link_dict['read'] = {"value" : read,
"unit" : data_unit}
@@ -5350,8 +5350,8 @@ class AMDSMICommands():
tabular_output.append(tabular_output_dict)
# Create Read and Write rows and add to tabular_output
read_output_dict = {"RW" : "Read"}
write_output_dict = {"RW" : "Write"}
read_output_dict = {"RW" : " Read"}
write_output_dict = {"RW" : " Write"}
for key, value in xgmi_dict.items():
if key == "link_metrics":
for link_key, link_value in value.items():
+12 -2
Vedi File
@@ -779,10 +779,20 @@ class AMDSMIHelpers():
return False, profile_presets.values()
def convert_bytes_to_readable(self, bytes_input):
def convert_bytes_to_readable(self, bytes_input, format_length=None):
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
if abs(bytes_input) < 1024:
return f"{bytes_input:3.1f} {unit}"
if format_length is not None:
if bytes_input < 10:
return f"{bytes_input:4.3f} {unit}"
elif bytes_input < 100:
return f"{bytes_input:4.2f} {unit}"
elif bytes_input < 1000:
return f"{bytes_input:4.1f} {unit}"
else:
return f"{bytes_input:4.0f} {unit}"
else:
return f"{bytes_input:3.1f} {unit}"
bytes_input /= 1024
return f"{bytes_input:.1f} YB"