diff options
Diffstat (limited to 'scripts/histogram.py')
| -rwxr-xr-x | scripts/histogram.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/scripts/histogram.py b/scripts/histogram.py index 2dd3b6c..5bca21c 100755 --- a/scripts/histogram.py +++ b/scripts/histogram.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> +# +# This file is part of allocbench. +# +# allocbench is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# allocbench is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with allocbench. If not, see <http://www.gnu.org/licenses/>. + """Plot an interactive histogram from malt or chattymalloc output file""" import argparse @@ -15,7 +32,6 @@ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) -import src.chattyparser def main(): parser = argparse.ArgumentParser(description="Plot histograms using a malt or chattymalloc output file") @@ -30,11 +46,16 @@ def main(): fname = os.path.basename(fpath) # chattymalloc if fname.startswith("chatty") and fext == ".txt": - hist, calls, _ = src.chattyparser.parse(args.input_file, coll_size=False) + try: + chattyparser = importlib.import_module("chattyparser") + except ModuleNotFoundError as err: + print("Can't import chattyparser") + sys.exit(1) + hist, calls, _ = chattyparser.parse(args.input_file, coll_size=False) # malt else: with open(args.input_file, "r") as json_file: - malt_res = json.load(json_file) + malt_res = json.load(json_file) hist = malt_res["memStats"]["sizeMap"] calls = {} @@ -49,7 +70,7 @@ def main(): print(size, amount, file=csv_file) if not args.no_ascii: - src.chattyparser.plot_hist_ascii(f"{fpath}.hist.txt", hist, calls) + chattyparser.plot_hist_ascii(f"{fpath}.hist.txt", hist, calls) if args.interactive: sizes = [] |
