scripts: dbgtrace.py: Allow no-arg -w/--block-cycles to imply wear

This allows -w to provide a shortform flag for both --wear and
--block-cycles, depending on if you include a cycles argument:

- -w    => --wear
- -w100 => --block-cycles=100

I was originally hesitant to add this since it's inconsistent from
--read/--prog/--erase, which can't have shortforms due to flag
conflicts, but --wear is probably a special enough case.
This commit is contained in:
Christopher Haster
2025-04-12 14:32:10 -05:00
parent c63ed79c5f
commit 0af90ea44b
+8 -4
View File
@@ -1211,8 +1211,9 @@ def main(path='-', *,
sum((b.wear - wear_avg)**2 for b in bmap.values())
/ max(len(bmap), 1))
# if block_cycles isn't provide, scale based on max wear
if block_cycles is not None:
# if block_cycles isn't provided or is zero, scale based on
# max wear
if block_cycles:
block_cycles_ = block_cycles
else:
block_cycles_ = wear_max
@@ -1445,7 +1446,7 @@ def main(path='-', *,
ranges__ = RangeSet([range(block_size_)])
# scale char/color based on either block_cycles
# or wear_avg
if block_cycles is not None:
if block_cycles:
wear__ = min(b.wear / max(block_cycles, 1), 1.0)
else:
wear__ = min(b.wear / max(2*wear_avg, 1), 1.0)
@@ -1660,9 +1661,12 @@ if __name__ == "__main__":
help="Only render wear, don't render bd ops. Implies --wear.")
parser.add_argument(
'-w', '--block-cycles',
nargs='?',
type=lambda x: int(x, 0),
const=0,
help="Assumed maximum number of erase cycles when measuring "
"wear. Implies --wear.")
"wear. Defaults to the maximum wear on any single block. "
"Implies --wear.")
parser.add_argument(
'--volatile',
action='store_true',