Skip to content

Commit 1029f3e

Browse files
committed
CMD: add option to hide columns in results stats
1 parent 66af487 commit 1029f3e

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-29
lines changed

chb/app/AppResultFunctionMetrics.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def metrics_to_string(
237237
self,
238238
shownocallees: bool = False,
239239
space: str = " ",
240+
hide: List[str] = [],
240241
tags: List[str] = [],
241242
taglen: int = 0) -> str:
242243
callcount = ''
@@ -251,13 +252,25 @@ def metrics_to_string(
251252
if self.unresolved_call_count > 0:
252253
unrc = str(self.unresolved_call_count)
253254
if len(tags) > 0:
254-
ftags = (" [" + ",".join(tags) + "]").ljust(taglen)
255-
256-
return (str(self.faddr).ljust(10) + space
257-
+ '{:6.1f}'.format(self.espp) + space
258-
+ '{:6.1f}'.format(self.readsp) + space
259-
+ '{:6.1f}'.format(self.writesp) + space
260-
+ unrc.rjust(6) + space
261-
+ str(self.block_count).rjust(6) + space
262-
+ str(self.instruction_count).rjust(6) + space
263-
+ '{:8.3f}'.format(self.time) + ftags + name + callcount)
255+
ftags = space + ("[" + ",".join(tags) + "]").ljust(taglen)
256+
espp = "" if "esp" in hide else space + '{:6.1f}'.format(self.espp)
257+
readsp = "" if "reads" in hide else space + '{:6.1f}'.format(self.readsp)
258+
writesp = ("" if "writes" in hide
259+
else space + '{:6.1f}'.format(self.writesp))
260+
unrcp = ("" if "unrc" in hide else space + unrc.rjust(6))
261+
blocksp = ("" if "blocks" in hide
262+
else space + str(self.block_count).rjust(6))
263+
instrsp = ("" if "instrs" in hide
264+
else space + str(self.instruction_count).rjust(6))
265+
timep = "" if "time" in hide else space + '{:8.3f}'.format(self.time)
266+
return (str(self.faddr).ljust(10)
267+
+ espp
268+
+ readsp
269+
+ writesp
270+
+ unrcp
271+
+ blocksp
272+
+ instrsp
273+
+ timep
274+
+ ftags
275+
+ name
276+
+ callcount)

chb/app/AppResultMetrics.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -518,24 +518,24 @@ def analysis_to_string(self) -> str:
518518
lines.append('-' * 80)
519519
return '\n'.join(lines)
520520

521-
def header_to_string(self, space: str = " ") -> str:
521+
def header_to_string(self, space: str = " ", hide: List[str] = []) -> str:
522522
lines: List[str] = []
523523
lines.append('-' * 80)
524+
h_esp = "" if "esp" in hide else space + "esp".center(6)
525+
h_reads = "" if "reads" in hide else space + "reads".center(6)
526+
h_writes = "" if "writes" in hide else space + "writes".center(6)
527+
h_unrc = "" if "unrc" in hide else space + "unrc".center(6)
528+
h_blocks = "" if "blocks" in hide else space + "blocks".center(6)
529+
h_instrs = "" if "instrs" in hide else space + "instrs".center(6)
530+
h_time = "" if "time" in hide else space + "time".center(8)
524531
lines.append(
525-
'function '
526-
+ space
527-
+ 'esp'.center(6)
528-
+ space
529-
+ 'reads'.center(6)
530-
+ space
531-
+ 'writes'.center(6)
532-
+ space
533-
+ 'unrc'.center(6)
534-
+ space
535-
+ 'blocks'.center(6)
536-
+ space
537-
+ 'instrs'.center(6)
538-
+ space
539-
+ 'time'.center(8))
532+
"function "
533+
+ h_esp
534+
+ h_reads
535+
+ h_writes
536+
+ h_unrc
537+
+ h_blocks
538+
+ h_instrs
539+
+ h_time)
540540
lines.append('-' * 80)
541541
return '\n'.join(lines)

chb/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chbversion: str = "0.3.0-20250401"
1+
chbversion: str = "0.3.0-20250403"

chb/cmdline/chkx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,12 @@ def parse() -> argparse.Namespace:
615615
resultsstats.add_argument(
616616
"--tagfile",
617617
help="name of json file that has function tags")
618+
resultsstats.add_argument(
619+
"--hide",
620+
help="name(s) of columns to hide",
621+
nargs="*",
622+
choices=["time", "esp","reads","writes", "unrc"],
623+
default=[])
618624
resultsstats.add_argument(
619625
"--loglevel", "-log",
620626
choices=UL.LogLevel.options(),

chb/cmdline/commandutil.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ def results_stats(args: argparse.Namespace) -> NoReturn:
619619
sortby: str = args.sortby
620620
timeshare: int = args.timeshare
621621
opcodes: str = args.opcodes
622+
hide: List[str] = args.hide
622623
tagfile: Optional[str] = args.tagfile
623624
loglevel: str = args.loglevel
624625
logfilename: Optional[str] = args.logfilename
@@ -661,7 +662,7 @@ def results_stats(args: argparse.Namespace) -> NoReturn:
661662
app = get_app(path, xfile, xinfo)
662663

663664
stats = app.result_metrics
664-
print(stats.header_to_string())
665+
print(stats.header_to_string(hide=hide))
665666
if sortby == "instrs":
666667
sortkey = lambda f: f.instruction_count
667668
elif sortby == "basicblocks":
@@ -679,7 +680,7 @@ def results_stats(args: argparse.Namespace) -> NoReturn:
679680
fn_tags = []
680681
if "hide" in fn_tags:
681682
continue
682-
print(f.metrics_to_string(shownocallees=nocallees,
683+
print(f.metrics_to_string(shownocallees=nocallees, hide=hide,
683684
tags=fn_tags, taglen=maxlen))
684685

685686
print(stats.disassembly_to_string())

0 commit comments

Comments
 (0)