diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-03-02 12:09:06 -0800 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-03-02 12:09:06 -0800 |
commit | 27a8ff5a92eb23404931d069b87ab021bf44e092 (patch) | |
tree | 21e880fbd0d2840ef234cc0be95d040337f214df | |
parent | 987ca185ac507c92f4f29d8b7c4ed8f8f106c494 (diff) | |
download | damo-27a8ff5a92eb23404931d069b87ab021bf44e092.tar.gz |
damo_report: Add times report format
When using damo together with other program such as profilers, it is
useful to know when specific access pattern has happened. Add a report
format for the information.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | damo_report.py | 6 | ||||
-rw-r--r-- | damo_report_times.py | 64 |
2 files changed, 69 insertions, 1 deletions
diff --git a/damo_report.py b/damo_report.py index 4bdd5d13..f029d5e9 100644 --- a/damo_report.py +++ b/damo_report.py @@ -7,6 +7,7 @@ import damo_heats import damo_nr_regions import damo_report_profile import damo_report_raw +import damo_report_times import damo_wss subcmds = [ @@ -19,7 +20,10 @@ subcmds = [ _damo_subcmds.DamoSubCmd(name='nr_regions', module=damo_nr_regions, msg='number of regions'), _damo_subcmds.DamoSubCmd(name='profile', module=damo_report_profile, - msg='profile report for specific access pattern')] + msg='profile report for specific access pattern'), + _damo_subcmds.DamoSubCmd(name='times', module=damo_report_times, + msg='times of record having specific access pattern'), + ] def main(args): for subcmd in subcmds: diff --git a/damo_report_times.py b/damo_report_times.py new file mode 100644 index 00000000..b71a1c83 --- /dev/null +++ b/damo_report_times.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0 + +import argparse +import subprocess + +import _damon +import _damon_records +import damo_show + +def main(args): + access_pattern = _damon.DamosAccessPattern(args.sz_region, + args.access_rate, _damon.unit_percent, args.age * 1000000, + _damon.unit_usec) + + addr_range = None + if args.address != None: + addr_range, err = damo_show.parse_sort_addr_ranges_input(args.address) + if err != None: + print('wrong --address input (%s)' % err) + exit(1) + + records, err = _damon_records.get_records( + tried_regions_of=False, record_file=args.inputs[0], + access_pattern=access_pattern, address_ranges=addr_range, + total_sz_only=False, dont_merge_regions=False) + if err != None: + print(err) + exit(1) + + times = [] + for record in records: + for snapshot in record.snapshots: + if len(snapshot.regions) == 0: + continue + if len(times) == 0: + times.append([snapshot.start_time, snapshot.end_time]) + continue + last_time = times[-1] + if last_time[1] == snapshot.start_time: + last_time[1] = snapshot.end_time + else: + times.append([snapshot.start_time, snapshot.end_time]) + + for interval in times: + print('-'.join(['%f' % (t / 1000000000) for t in interval])) + +def set_argparser(parser): + parser.add_argument('--inputs', metavar='<file>', nargs=2, + default=['damon.data', 'damon.data.profile'], + help='access pattern and profile record files') + parser.add_argument('--sz_region', metavar=('<min>', '<max>'), nargs=2, + default=['min', 'max'], + help='min/max size of regions (bytes) to show') + parser.add_argument('--access_rate', metavar=('<min>', '<max>'), nargs=2, + default=['min', 'max'], + help='min/max access rate of regions (percent) to show') + parser.add_argument('--age', metavar=('<min>', '<max>'), nargs=2, + default=['min', 'max'], + help='min/max age of regions (seconds) to show') + parser.add_argument('--address', metavar=('<start>', '<end>'), nargs=2, + action='append', + help='address ranges to show') + + parser.description='Show times of record having specific access pattern' |