7import matplotlib.pyplot
as plt
9import exahype2.postprocessing
12if __name__ ==
"__main__":
13 parser = argparse.ArgumentParser(description=
"""
14ExaHyPE 2 runtime plotter:
16Default plotter for various standard ExaHyPE dumps. The plotter examines
17and illustrates the runtime per time step behaviour.
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"
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()
36 for dataset
in zip( args.file, args.label) :
37 performance_data = exahype2.postprocessing.PerformanceData( file_name=dataset[0], verbose=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] )
57 raise Exception(
"Type " + args.type +
" not supported" )
59 print(
"postprocessing finished" )
64 if args.output==
"output":
65 print(
"default file names output.pdf and output.png written. Change file name with -o or --output")
67 plt.savefig( args.output +
".pdf" )
68 plt.savefig( args.output +
".png" )