Skip to content

Commit 79577ab

Browse files
committed
fix percentage report for file-based results
1 parent 0ed52cd commit 79577ab

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

drishti/main.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -545,38 +545,41 @@ def main():
545545
# Get the files responsible for more than half of these accesses
546546
files = []
547547

548-
df['counters']['INSIGHTS_POSIX_SMALL'] = (
548+
df['counters']['INSIGHTS_POSIX_SMALL_READ'] = (
549549
df['counters']['POSIX_SIZE_READ_0_100'] +
550550
df['counters']['POSIX_SIZE_READ_100_1K'] +
551551
df['counters']['POSIX_SIZE_READ_1K_10K'] +
552552
df['counters']['POSIX_SIZE_READ_10K_100K'] +
553-
df['counters']['POSIX_SIZE_WRITE_100K_1M'] +
553+
df['counters']['POSIX_SIZE_READ_100K_1M']
554+
)
555+
556+
df['counters']['INSIGHTS_POSIX_SMALL_WRITE'] = (
554557
df['counters']['POSIX_SIZE_WRITE_0_100'] +
555558
df['counters']['POSIX_SIZE_WRITE_100_1K'] +
556559
df['counters']['POSIX_SIZE_WRITE_1K_10K'] +
557560
df['counters']['POSIX_SIZE_WRITE_10K_100K'] +
558561
df['counters']['POSIX_SIZE_WRITE_100K_1M']
559562
)
560563

561-
detected_files = pd.DataFrame(df['counters'].groupby('id')['INSIGHTS_POSIX_SMALL'].sum()).reset_index()
562-
detected_files.columns = ['id', 'total']
564+
detected_files = pd.DataFrame(df['counters'].groupby('id')[['INSIGHTS_POSIX_SMALL_READ', 'INSIGHTS_POSIX_SMALL_WRITE']].sum()).reset_index()
565+
detected_files.columns = ['id', 'total_reads', 'total_writes']
563566
detected_files.loc[:, 'id'] = detected_files.loc[:, 'id'].astype(str)
564567

565568
if total_reads_small and total_reads_small / total_reads > THRESHOLD_SMALL_REQUESTS and total_reads_small > THRESHOLD_SMALL_REQUESTS_ABSOLUTE:
566-
issue = 'Application issues a high number ({}) of small read requests (i.e., < 1MB) which represents {:.2f}% of all read/write requests'.format(
569+
issue = 'Application issues a high number ({}) of small read requests (i.e., < 1MB) which represents {:.2f}% of all read requests'.format(
567570
total_reads_small, total_reads_small / total_reads * 100.0
568571
)
569572

570573
detail = []
571574
recommendation = []
572575

573576
for index, row in detected_files.iterrows():
574-
if row['total'] > (total_reads * THRESHOLD_SMALL_REQUESTS / 2):
577+
if row['total_reads'] > (total_reads * THRESHOLD_SMALL_REQUESTS / 2):
575578
detail.append(
576579
{
577580
'message': '{} ({:.2f}%) small read requests are to "{}"'.format(
578-
row['total'],
579-
row['total'] / total_reads * 100.0,
581+
row['total_reads'],
582+
row['total_reads'] / total_reads * 100.0,
580583
file_map[int(row['id'])] if args.full_path else os.path.basename(file_map[int(row['id'])])
581584
)
582585
}
@@ -616,20 +619,20 @@ def main():
616619
)
617620

618621
if total_writes_small and total_writes_small / total_writes > THRESHOLD_SMALL_REQUESTS and total_writes_small > THRESHOLD_SMALL_REQUESTS_ABSOLUTE:
619-
issue = 'Application issues a high number ({}) of small write requests (i.e., < 1MB) which represents {:.2f}% of all read/write requests'.format(
622+
issue = 'Application issues a high number ({}) of small write requests (i.e., < 1MB) which represents {:.2f}% of all write requests'.format(
620623
total_writes_small, total_writes_small / total_writes * 100.0
621624
)
622625

623626
detail = []
624627
recommendation = []
625628

626629
for index, row in detected_files.iterrows():
627-
if row['total'] > (total_writes * THRESHOLD_SMALL_REQUESTS / 2):
630+
if row['total_writes'] > (total_writes * THRESHOLD_SMALL_REQUESTS / 2):
628631
detail.append(
629632
{
630633
'message': '{} ({:.2f}%) small write requests are to "{}"'.format(
631-
row['total'],
632-
row['total'] / total_writes * 100.0,
634+
row['total_writes'],
635+
row['total_writes'] / total_writes * 100.0,
633636
file_map[int(row['id'])] if args.full_path else os.path.basename(file_map[int(row['id'])])
634637
)
635638
}

0 commit comments

Comments
 (0)