Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Add total duration column to stats #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lttnganalyses/cli/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class IoAnalysisCommand(Command):
('max_latency', 'Maximum call latency', mi.Duration),
('stdev_latency', 'System call latency standard deviation',
mi.Duration),
('total_latency', 'Total call latency', mi.Duration),
]
),
(
Expand All @@ -98,6 +99,7 @@ class IoAnalysisCommand(Command):
('max_latency', 'Maximum access latency', mi.Duration),
('stdev_latency', 'System access latency standard deviation',
mi.Duration),
('total_latency', 'Total call latency', mi.Duration),
]
),
(
Expand Down Expand Up @@ -188,8 +190,8 @@ class IoAnalysisCommand(Command):
]
),
]
_LATENCY_STATS_FORMAT = '{:<14} {:>14} {:>14} {:>14} {:>14} {:>14}'
_SECTION_SEPARATOR_STRING = '-' * 89
_LATENCY_STATS_FORMAT = '{:<14} {:>14} {:>14} {:>14} {:>14} {:>14} {:>14}'
_SECTION_SEPARATOR_STRING = '-' * 104

def _analysis_tick(self, period_data, end_ns):
if period_data is None:
Expand Down Expand Up @@ -1059,6 +1061,7 @@ def _append_latency_stats_row(self, obj, rq_durations, result_table):
avg_latency=mi.Duration(avg),
max_latency=mi.Duration(max_duration),
stdev_latency=stdev,
total_latency=mi.Duration(total_duration),
)

def _append_latency_stats_row_from_requests(self, obj, io_requests,
Expand Down Expand Up @@ -1114,17 +1117,18 @@ def _print_latency_stats_row(self, row):
stdev = '%0.03f' % row.stdev_latency.to_us()

avg = '%0.03f' % row.avg_latency.to_us()
total_duration = '%0.03f' % row.total_latency.to_us()
min_duration = '%0.03f' % row.min_latency.to_us()
max_duration = '%0.03f' % row.max_latency.to_us()

print(IoAnalysisCommand._LATENCY_STATS_FORMAT.format(
str(row.obj), row.count.value, min_duration,
avg, max_duration, stdev))
avg, max_duration, stdev, total_duration))

def _print_syscall_latency_stats(self, stats_table):
print('\nSyscalls latency statistics (usec):')
print(IoAnalysisCommand._LATENCY_STATS_FORMAT.format(
'Type', 'Count', 'Min', 'Average', 'Max', 'Stdev'))
'Type', 'Count', 'Min', 'Average', 'Max', 'Stdev', 'Total'))
print(IoAnalysisCommand._SECTION_SEPARATOR_STRING)

for row in stats_table.rows:
Expand All @@ -1136,7 +1140,7 @@ def _print_disk_latency_stats(self, stats_table):

print('\nDisk latency statistics (usec):')
print(IoAnalysisCommand._LATENCY_STATS_FORMAT.format(
'Name', 'Count', 'Min', 'Average', 'Max', 'Stdev'))
'Name', 'Count', 'Min', 'Average', 'Max', 'Stdev', 'Total'))
print(IoAnalysisCommand._SECTION_SEPARATOR_STRING)

for row in stats_table.rows:
Expand Down
19 changes: 14 additions & 5 deletions lttnganalyses/cli/syscallstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SyscallsAnalysis(Command):
('max_duration', 'Maximum call duration', mi.Duration),
('stdev_duration', 'Call duration standard deviation',
mi.Duration),
('total_duration', 'Total call duration', mi.Duration),
('return_values', 'Return values count', mi.String),
]
),
Expand Down Expand Up @@ -172,6 +173,7 @@ def _get_result_tables(self, period_data, begin_ns, end_ns):
syscall.count),
max_duration=mi.Duration(syscall.max_duration),
stdev_duration=stdev,
total_duration=mi.Duration(syscall.total_duration),
return_values=mi.String(str(return_count)),
)

Expand All @@ -185,39 +187,46 @@ def _get_result_tables(self, period_data, begin_ns, end_ns):
return total_table, per_tid_tables

def _print_results(self, total_table, per_tid_tables):
line_format = '{:<38} {:>14} {:>14} {:>14} {:>12} {:>10} {:<14}'
line_format = '{:<38} {:>14} {:>14} {:>14} {:>12} {:>10} {:>14} {:<14}'

print('Per-TID syscalls statistics (usec)')
total_calls = 0
total_duration = 0

for total_row, table in zip(total_table.rows, per_tid_tables):
print(line_format.format(table.subtitle,
'Count', 'Min', 'Average', 'Max',
'Stdev', 'Return values'))
'Stdev', 'Total', 'Return values'))
proc_total_duration = 0
for row in table.rows:
syscall_name = row.syscall.name
syscall_count = row.count.value
min_duration = round(row.min_duration.to_us(), 3)
avg_duration = round(row.avg_duration.to_us(), 3)
max_duration = round(row.max_duration.to_us(), 3)
row_total_duration = round(row.total_duration.to_us(), 3)
proc_total_duration += row.total_duration.to_us()

if type(row.stdev_duration) is mi.Unknown:
stdev = '?'
else:
stdev = round(row.stdev_duration.to_us(), 3)

proc_total_calls = total_row.count.value
print(line_format.format(
' - ' + syscall_name, syscall_count, min_duration,
avg_duration, max_duration, stdev,
avg_duration, max_duration, stdev, row_total_duration,
row.return_values.value))

proc_total_calls = total_row.count.value
total_duration += proc_total_duration
proc_total_duration = round(proc_total_duration, 3)
print(line_format.format('Total:', proc_total_calls,
'', '', '', '', ''))
'', '', '', '', proc_total_duration, ''))
print('-' * 113)
total_calls += proc_total_calls

print('\nTotal syscalls: %d' % (total_calls))
print('\nTotal duration: %f' % (total_duration))

def _add_arguments(self, ap):
Command._add_proc_filter_args(ap)
Expand Down