-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #903 from darshan-hpc/snyder/pydarshan-posix-acces…
…s-pattern WIP, ENH: add POSIX access pattern plot to darshan job summary
- Loading branch information
Showing
6 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
darshan-util/pydarshan/darshan/experimental/plots/plot_posix_access_pattern.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
def autolabel(ax, rects): | ||
"""Attach a text label above each bar in *rects*, displaying its value.""" | ||
for rect in rects: | ||
height = rect.get_height() | ||
ax.annotate( | ||
'{}'.format(height), | ||
xy=(rect.get_x() + rect.get_width() / 2, height), | ||
xytext=(0, 3), # 3 points vertical offset | ||
textcoords="offset points", | ||
ha='center', | ||
va='bottom', | ||
rotation=45, | ||
) | ||
|
||
def plot_posix_access_pattern(record, ax=None): | ||
""" | ||
Plots read/write access patterns (sequential vs consecutive access counts) | ||
for a given POSIX module file record. | ||
Args: | ||
record (dict): POSIX module record to plot access pattern for. | ||
""" | ||
|
||
if ax is None: | ||
fig, ax = plt.subplots() | ||
else: | ||
fig = None | ||
|
||
labels = ['read', 'write'] | ||
total_data = [record['counters']['POSIX_READS'][0], | ||
record['counters']['POSIX_WRITES'][0]] | ||
seq_data = [record['counters']['POSIX_SEQ_READS'][0], | ||
record['counters']['POSIX_SEQ_WRITES'][0]] | ||
consec_data = [record['counters']['POSIX_CONSEC_READS'][0], | ||
record['counters']['POSIX_CONSEC_WRITES'][0]] | ||
|
||
x = np.arange(len(labels)) # the label locations | ||
width = 0.2 # the width of the bars | ||
|
||
rects_total = ax.bar(x - width, total_data, width, label = 'total') | ||
rects_seq = ax.bar(x, seq_data, width, label = 'sequential') | ||
rects_consec = ax.bar(x + width, consec_data, width, label = 'consecutive') | ||
|
||
ax.set_ylabel('Count') | ||
ax.set_xticks(x) | ||
ax.set_xticklabels(labels) | ||
ax.legend(loc='center left', bbox_to_anchor=(1.05,.5)) | ||
|
||
ax.spines[['right', 'top']].set_visible(False) | ||
|
||
autolabel(ax=ax, rects=rects_total) | ||
autolabel(ax=ax, rects=rects_seq) | ||
autolabel(ax=ax, rects=rects_consec) | ||
|
||
plt.tight_layout() | ||
|
||
if fig is not None: | ||
plt.close() | ||
return fig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters