Peano
Loading...
Searching...
No Matches
plot-runtime-behaviour.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import sys
5import argparse
6
7import matplotlib.pyplot as plt
8
9import exahype2.postprocessing
10
11
12if __name__ == "__main__":
13 parser = argparse.ArgumentParser(description="""
14ExaHyPE 2 runtime plotter:
15
16Default plotter for various standard ExaHyPE dumps. The plotter examines
17and illustrates the runtime per time step behaviour.
18
19""")
20 parser.add_argument("file", nargs="+", help="Filename of the file to parse. You can specify multiple files.")
21 parser.add_argument("-v", "--verbose", dest="verbose", help="Increase output verbosity", action="store_true", default=False )
22 parser.add_argument("-log-y", "--log-ysaxis", dest="log_yscale", help="Use log scale", action="store_true", default=False )
23 parser.add_argument("-t", "--type", dest="type", help="Pick plot variant", choices=[
24 "time-step-size-vs-time-step", "time-step-size-vs-real-time", "time-step-size-vs-simulated-time",
25 "updates-vs-time-step", "updates-vs-real-time", "updates-vs-simulated-time",
26 "runtime-vs-time-step", "runtime-vs-simulated-time"
27 ], required=True )
28 parser.add_argument("-l", "--label", dest="label", nargs="*", help="Label of dataset (optional; if used, you have to add --label/-l after the actual files and you have to embed the labels into hyphens)", default="output" )
29 parser.add_argument("-o", "--output", dest="output", help="Name of output file", default="output" )
30 args = parser.parse_args()
31
32 plt.clf()
33 if args.log_yscale:
34 plt.yscale( 'log' )
35
36 for dataset in zip( args.file, args.label) :
37 performance_data = exahype2.postprocessing.PerformanceData( file_name=dataset[0], verbose=args.verbose )
38 if args.verbose:
39 print( "start to postprocess data with " + args.type )
40 if args.type == "time-step-size-vs-time-step":
41 exahype2.postprocessing.plot_time_step_size_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.Iterations )
42 elif args.type == "time-step-size-vs-real-time":
43 exahype2.postprocessing.plot_time_step_size_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.RealTime )
44 elif args.type == "time-step-size-vs-simulated-time":
45 exahype2.postprocessing.plot_time_step_size_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.SimulatedTime )
46 elif args.type == "updates-vs-time-step":
47 exahype2.postprocessing.plot_updates_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.Iterations )
48 elif args.type == "updates-vs-real-time":
49 exahype2.postprocessing.plot_updates_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.RealTime )
50 elif args.type == "updates-vs-simulated-time":
51 exahype2.postprocessing.plot_updates_per_step( performance_data,dataset[1], exahype2.postprocessing.XAxis.SimulatedTime )
52 elif args.type == "runtime-vs-time-step":
53 exahype2.postprocessing.plot_runtime_per_step( performance_data,dataset[1] )
54 elif args.type == "runtime-vs-simulated-time":
55 exahype2.postprocessing.plot_runtime_against_simulated_time( performance_data,dataset[1] )
56 else:
57 raise Exception( "Type " + args.type + " not supported" )
58 if args.verbose:
59 print( "postprocessing finished" )
60
61 if len(args.label)>0:
62 plt.legend()
63
64 if args.output=="output":
65 print( "default file names output.pdf and output.png written. Change file name with -o or --output")
66
67 plt.savefig( args.output + ".pdf" )
68 plt.savefig( args.output + ".png" )