aboutsummaryrefslogtreecommitdiff
path: root/size-data-to-csv.py
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2024-03-21 21:05:38 +0530
committerPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2024-03-21 21:05:38 +0530
commit65929a0fe896437601769d610797cbce62654b6e (patch)
tree31335fd943d92a8a40922ca6f899a9f3f49a16cf /size-data-to-csv.py
parent393a9ea9d3db2eee0ae8853c63c311e81c941761 (diff)
Pass status.csv to metric files.
This patch introduces a new option --status_csv for passing status.csv to metric computing scripts (*-data-to-csv.py), and merge status field in merge-metric-csvs.py. Change-Id: If4fa4f7f99c1cdc574c326422b03b87d7af3dc71
Diffstat (limited to 'size-data-to-csv.py')
-rwxr-xr-xsize-data-to-csv.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/size-data-to-csv.py b/size-data-to-csv.py
index c88cf12..9d5b1d2 100755
--- a/size-data-to-csv.py
+++ b/size-data-to-csv.py
@@ -5,11 +5,12 @@ import csv
import subprocess
import os
import metric_utils
+import pandas as pd
"""
Parse output of nm -S -td."""
-def get_symbol_size(symbol_to_size, perf_bmk_symbols, exe_path):
+def get_symbol_size(symbol_to_size, interesting_symbols, exe_path):
try:
lines = subprocess.check_output(["nm", "-Std", exe_path], stderr=subprocess.DEVNULL).decode("utf-8").split("\n")
except subprocess.CalledProcessError as e:
@@ -20,7 +21,7 @@ def get_symbol_size(symbol_to_size, perf_bmk_symbols, exe_path):
# by nm. For eg, perf.csv may contain malloc@plt as symbol name,
# but nm will list malloc.
plt_entries = set()
- for symbol in perf_bmk_symbols:
+ for symbol in interesting_symbols:
if symbol.endswith("@plt"):
plt_entries.add(symbol)
@@ -33,11 +34,13 @@ def get_symbol_size(symbol_to_size, perf_bmk_symbols, exe_path):
# Some symbols may contain @libc prefix for eg, puts@GLIBC_2.2.5
# Strip the @<lib> from symbol name.
symbol = symbol[: symbol.find("@")] if symbol.find("@") != -1 else symbol
+ if symbol not in interesting_symbols:
+ continue
# FIXME: Size is accumulated for static symbols in different
# TU's having same name.
if section.lower() == 't' or section.lower() == 'w' \
- or symbol in perf_bmk_symbols or symbol in plt_entries:
+ or symbol in plt_entries:
if symbol not in symbol_to_size:
symbol_to_size[symbol] = 0
symbol_to_size[symbol] += size
@@ -54,28 +57,32 @@ def main():
out_csv_file = args.out_csv_file
perf_csv = args.perf_csv
results_dir = args.results_dir
+ interesting_symbols_csv = args.interesting_symbols
+ status_df = pd.read_csv(args.status_csv)
outf = open(out_csv_file, "w")
csvwriter = csv.writer(outf)
csvwriter.writerow(("benchmark", "symbol", "size"))
- benchmarks = metric_utils.get_benchmarks_from_results_dir(bmk_name, results_dir)
+ benchmarks = metric_utils.get_benchmarks_from_results_dir(bmk_name, results_dir, status_df)
for bmk in benchmarks:
exe = bmk.exe
if exe is None:
continue
- # Get symbols from perf.csv. We ensure that size for all symbols from
- # perf.csv is calculcated.
- perf_bmk_symbols = metric_utils.get_bmk_symbols_from_perf(perf_csv, bmk.name)
-
+ if interesting_symbols_csv:
+ sym_dso_map = metric_utils.get_bmk_symbols_from_perf(interesting_symbols_csv, bmk.name, True)
+ else:
+ sym_dso_map = metric_utils.get_bmk_symbols_from_perf(perf_csv, bmk.name)
+ interesting_symbols = set(sym_dso_map.keys())
+
# FIXME: For now, accumulate size for symbols with same name across main exe and libraries.
# So sym_to_size now contains symbols across the main exe and libs, with
# one entry for common symbols.
- sym_to_size = get_symbol_size({}, perf_bmk_symbols, exe.path)
+ sym_to_size = get_symbol_size({}, interesting_symbols, exe.path)
libs = exe.libs
for libname in libs:
- sym_to_size = get_symbol_size(sym_to_size, perf_bmk_symbols, libs[libname])
+ sym_to_size = get_symbol_size(sym_to_size, interesting_symbols, libs[libname])
# Write entry for libs: bmk, libname, total lib size
csvwriter.writerow((bmk.name, exe.name, calculate_size(exe.path)))