diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-10-14 01:31:32 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-10-14 01:31:32 +0200 |
| commit | 74a2dd607a44d871556cf86b602c7968f31ddcd0 (patch) | |
| tree | 4874463b17365b834560b3c3534bdd9d8e0468d9 /src/chattyparser.py | |
| parent | 5c4edad3455bf2a77382a17a8acbeda075e129c0 (diff) | |
| download | allocbench-74a2dd607a44d871556cf86b602c7968f31ddcd0.tar.gz allocbench-74a2dd607a44d871556cf86b602c7968f31ddcd0.zip | |
produce ascii histograms with scripts/matplotlib_histograms.py
Add new options to matplotlib_histograms.py:
-i - open interactive matplotlib plots
-n - no ascii histogram
chattyparser.plot_hist_ascii handles histograms with non int keys
Diffstat (limited to 'src/chattyparser.py')
| -rwxr-xr-x | src/chattyparser.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/chattyparser.py b/src/chattyparser.py index 4e4acae..87a5c05 100755 --- a/src/chattyparser.py +++ b/src/chattyparser.py @@ -177,17 +177,21 @@ def plot_profile(total_sizes, trace_path, plot_path, sizes): def plot_hist_ascii(path, hist, calls): """Plot an ascii histogram""" + # make sure all sizes are stored as ints + for nonint_key in [key for key in hist.keys() if type(key) is not int]: + hist[int(nonint_key)] = hist[nonint_key] + del hist[nonint_key] + bins = {} for size in sorted(hist): - size_class = int(size / 16) + size_class = size / 16 bins[size_class] = bins.get(size_class, 0) + hist[size] - total = sum(calls.values()) - calls["free"] with open(path, "w") as hist_file: - print("Total function calls:", total, file=hist_file) - for func in TRACE_REGEX: - print(func, calls[func], file=hist_file) + print("Total function calls:", sum(calls.values()), file=hist_file) + for func, func_calls in calls.items(): + print(func, func_calls, file=hist_file) print(file=hist_file) @@ -201,6 +205,7 @@ def plot_hist_ascii(path, hist, calls): print(file=hist_file) print("Histogram of sizes:", file=hist_file) + total = sum(hist.values()) sbins = sorted(bins) binmaxlength = str(len(str(sbins[-1])) + 1) amountmaxlength = str(len(str(sorted(bins.values())[-1]))) @@ -220,7 +225,7 @@ if __name__ == "__main__": print("License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>") exit(0) - if len(sys.argv) != 2: + if len(sys.argv) != 2 or sys.argv[1] in ["-h", "--help"]: print("chattyparser: parse chattymalloc output and", "create size histogram and memory profile", file=sys.stderr) print(f"Usage: {sys.argv[0]} chattymalloc-file", file=sys.stderr) |
