From 9774f900f7354488500cfaaed61a2edcd775b8a0 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 20 Aug 2019 16:04:34 +0200 Subject: rename histogram script to malt_histogram --- scripts/histogram.py | 58 ----------------------------------------------- scripts/malt_histogram.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 58 deletions(-) delete mode 100755 scripts/histogram.py create mode 100755 scripts/malt_histogram.py diff --git a/scripts/histogram.py b/scripts/histogram.py deleted file mode 100755 index 122035e..0000000 --- a/scripts/histogram.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import json -import matplotlib.pyplot as plt - - -parser = argparse.ArgumentParser(description="Plot interactive histogram using a malt json output file") -parser.add_argument("malt_output_file", help="path to malt output file", type=str) -parser.add_argument("-e", "--export", help="export to csv", action="store_true") - -def main(): - args = parser.parse_args() - - with open(args.malt_output_file, "r") as f: - res = json.load(f) - - if args.export: - with open(args.malt_output_file.replace("json", "csv"), "w") as f: - print("Size", "Amount", file=f) - for size, amount in res["memStats"]["sizeMap"].items(): - print(size, amount, file=f) - - else: - sizes = [] - sizes_smaller_4K = [] - sizes_smaller_32K = [] - sizes_bigger_32K = [] - for size, amount in res["memStats"]["sizeMap"].items(): - size = int(size) - sizes += [int(size)] * amount - if size < 4096: - sizes_smaller_4K += [int(size)] * amount - if size < 32000: - sizes_smaller_32K += [int(size)] * amount - else: - sizes_bigger_32K += [int(size)] * amount - - - plt.figure(0) - plt.hist(sizes_smaller_4K, 200) - plt.title("Sizes smaller than 4K") - - plt.figure(1) - plt.hist(sizes_smaller_32K, 200) - plt.title("Sizes smaller than 32K") - - plt.figure(2) - plt.hist(sizes_bigger_32K, 200) - plt.title("Sizes bigger than 32K") - - plt.figure(3) - plt.hist(sizes, 200) - plt.title("All sizes") - plt.show() - -if __name__ == "__main__": - main() diff --git a/scripts/malt_histogram.py b/scripts/malt_histogram.py new file mode 100755 index 0000000..122035e --- /dev/null +++ b/scripts/malt_histogram.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import argparse +import json +import matplotlib.pyplot as plt + + +parser = argparse.ArgumentParser(description="Plot interactive histogram using a malt json output file") +parser.add_argument("malt_output_file", help="path to malt output file", type=str) +parser.add_argument("-e", "--export", help="export to csv", action="store_true") + +def main(): + args = parser.parse_args() + + with open(args.malt_output_file, "r") as f: + res = json.load(f) + + if args.export: + with open(args.malt_output_file.replace("json", "csv"), "w") as f: + print("Size", "Amount", file=f) + for size, amount in res["memStats"]["sizeMap"].items(): + print(size, amount, file=f) + + else: + sizes = [] + sizes_smaller_4K = [] + sizes_smaller_32K = [] + sizes_bigger_32K = [] + for size, amount in res["memStats"]["sizeMap"].items(): + size = int(size) + sizes += [int(size)] * amount + if size < 4096: + sizes_smaller_4K += [int(size)] * amount + if size < 32000: + sizes_smaller_32K += [int(size)] * amount + else: + sizes_bigger_32K += [int(size)] * amount + + + plt.figure(0) + plt.hist(sizes_smaller_4K, 200) + plt.title("Sizes smaller than 4K") + + plt.figure(1) + plt.hist(sizes_smaller_32K, 200) + plt.title("Sizes smaller than 32K") + + plt.figure(2) + plt.hist(sizes_bigger_32K, 200) + plt.title("Sizes bigger than 32K") + + plt.figure(3) + plt.hist(sizes, 200) + plt.title("All sizes") + plt.show() + +if __name__ == "__main__": + main() -- cgit v1.2.3