def get__timechart(process, svg_chart): # Setup Time Lines event_time_series_filename = timestamp("event_time_series.svg") event_ratio_time_series_filename = timestamp("event_ratio_time_series.svg") event_time_series_output_file = ( GlobalData.local_data + os.sep + event_time_series_filename ) event_ratio_time_series_output_file = ( GlobalData.local_data + os.sep + event_ratio_time_series_filename ) event_time_series_title = "(Event Counts / second) for {}".format(process) event_ratio_time_series_title = "Event Ratios for {}".format(process) chart = svg_chart.generate_timechart( all_stack_data[process], process_model.start, process_model.stop, title=event_time_series_title, event_type="original", ) chart.render_to_file(event_time_series_output_file) chart = svg_chart.generate_timechart( all_stack_data[process], process_model.start, process_model.stop, title=event_ratio_time_series_title, event_type="custom_event_ratio", ) chart.render_to_file(event_ratio_time_series_output_file) svgfile1 = GlobalData.local_data + os.sep + event_time_series_filename svgfile1 = os.path.relpath(svgfile1, ProcessView.template_folder) svgfile2 = GlobalData.local_data + os.sep + event_ratio_time_series_filename svgfile2 = os.path.relpath(svgfile2, ProcessView.template_folder) return svgfile1, svgfile2
def get_barchart(process_list, hotspots, svg_chart): # Setup Bar Chart barchart_filename = timestamp("barchart.svg") output_file = GlobalData.local_data + os.sep + barchart_filename event_totals_chart_title = "Total Event count for selected Events/Threads: Reference = {}".format( analysis_model.reference_id) output_event_type = "original" chart = svg_chart.generate_vertical_stacked_bar_chart_multiple_jobs( all_stack_data, process_list, analysis_model.reference_process, analysis_model.reference_id, start=hotspots, title=event_totals_chart_title, output_event_type=output_event_type, write_colourmap=True, ) chart.render_to_file(output_file) try: event_totals_table = chart.render_table(style=False, transpose=True, total=True) except Exception as e: event_totals_table = "" svgfile = GlobalData.local_data + os.sep + barchart_filename svgfile = os.path.relpath(svgfile, AnalysisView.template_folder) return svgfile, event_totals_table
def get_flamegraph(process, flamegraph_event_type="original"): # Setup flamegraph flamegraph_type = "plot_for_process" write_flamegraph_stacks( all_stack_data[process], flamegraph_type, output_event_type=flamegraph_event_type, ) color_map = svgchart.get_flamegraph_colour_map() flamegraph_filename = timestamp("flamegraph.svg") collapsed_stacks_filename = all_stack_data[process].get_collapsed_stacks_filename() if flamegraph_event_type == "custom_event_ratio": FlameGraph( GlobalData.local_data, collapsed_stacks_filename, flamegraph_filename, custom_event_ratio=True, ) else: # original FlameGraph( GlobalData.local_data, collapsed_stacks_filename, flamegraph_filename, color_map=color_map, custom_event_ratio=False, ) svgfile = GlobalData.local_data + os.sep + flamegraph_filename svgfile = os.path.relpath(svgfile, ProcessView.template_folder) return svgfile
def get_flamegraph(flamegraph_type, job, start, stop): # Setup flamegraph write_flamegraph_stacks(all_stack_data[job], flamegraph_type, start, stop) flamegraph_filename = timestamp("flamegraph.svg") collapsed_stacks_filename = all_stack_data[ job].get_collapsed_stacks_filename() if flamegraph_type == "trace": augmented = True sort_by_time = False else: augmented = False sort_by_time = True event_type = all_stack_data[job].get_trace_event_type() if event_type == "clock": unit = "μs" # xml unicode: micro-seconds else: unit = "events" hotspots = all_stack_data[job].get_hotspots(augmented=augmented) colors = get_top_ten_colours() color_map = {h: colors[hotspots[h]] for h in hotspots} FlameGraph( GlobalData.local_data, collapsed_stacks_filename, flamegraph_filename, color_map=color_map, sort_by_time=sort_by_time, unit=unit, ) svgfile = GlobalData.local_data + os.sep + flamegraph_filename svgfile = os.path.relpath(svgfile, TraceView.template_folder) return svgfile
def get_custom_barchart(process, svg_chart): event_ratios_chart_title = "Average Event Ratios for {}: Reference = {}".format( process, process_model.reference_id ) custom_barchart_filename = timestamp("custom_barchart.svg") output_file = GlobalData.local_data + os.sep + custom_barchart_filename chart = svg_chart.generate_bar_chart( all_stack_data[process], title=event_ratios_chart_title, output_event_type="custom_event_ratio", ) chart.render_to_file(output_file) svgfile = GlobalData.local_data + os.sep + custom_barchart_filename svgfile = os.path.relpath(svgfile, ProcessView.template_folder) return svgfile
def get_custom_barchart(process_list, svg_chart): custom_barchart_filename = timestamp("custom_barchart.svg") output_file = GlobalData.local_data + os.sep + custom_barchart_filename event_totals_chart_title = "Total Event count for Event Ratios: Reference = {}".format( analysis_model.reference_id) output_event_type = "custom_event_ratio" chart = svg_chart.generate_bar_chart_multiple_jobs( all_stack_data, process_list, title=event_totals_chart_title, output_event_type=output_event_type, ) chart.render_to_file(output_file) svgfile = GlobalData.local_data + os.sep + custom_barchart_filename svgfile = os.path.relpath(svgfile, AnalysisView.template_folder) return svgfile
def get_hotspot_scatter_plot( analysis_data, event1, event2, svg_chart, centred, hotspots, log_scale=False, xlower=None, xupper=None, ylower=None, yupper=None, ): scatter_plot_filename = timestamp("scatter_plot.svg") output_file = GlobalData.local_data + os.sep + scatter_plot_filename cluster_chart_title = event1 + " vs " + event2 + ": hotspots" if log_scale: yt = "Log10(" + event1 + ")" xt = "Log10(" + event2 + ")" else: yt = event1 xt = event2 raw_event1 = event_to_raw_event(event1, GlobalData.loaded_cpu_definition) raw_event2 = event_to_raw_event(event2, GlobalData.loaded_cpu_definition) chart = svg_chart.generate_hotspot_scatter_plot( analysis_data, analysis_model.process_list, analysis_model.reference_process, analysis_model.reference_id, raw_event1, raw_event2, centred, start=hotspots, xlower=xlower, ylower=ylower, xupper=xupper, yupper=yupper, yt=yt, xt=xt, title=cluster_chart_title, ) chart.render_to_file(output_file) svgfile = GlobalData.local_data + os.sep + scatter_plot_filename svgfile = os.path.relpath(svgfile, AnalysisView.template_folder) return svgfile
def get_flamegraph(analysis_data, process_list, mode, flamegraph_event_type="original"): # Setup flamegraph flamegraph_type = "plot_for_process" if mode == "clusters": colours = get_top_ten_colours() color_map = analysis_data.get_flamegraph_colour_map(colours) else: # mode == "hotspots" color_map = svgchart.get_flamegraph_colour_map() first_process = True for process in process_list: write_flamegraph_stacks( all_stack_data[process], flamegraph_type, append=(not first_process), output_event_type=flamegraph_event_type, ) if first_process: collapsed_stacks_filename = all_stack_data[ process].get_collapsed_stacks_filename() first_process = False flamegraph_filename = timestamp("flamegraph.svg") flamegraph_description = {} if flamegraph_event_type == "custom_event_ratio": FlameGraph( GlobalData.local_data, collapsed_stacks_filename, flamegraph_filename, description=flamegraph_description, custom_event_ratio=True, ) else: # original FlameGraph( GlobalData.local_data, collapsed_stacks_filename, flamegraph_filename, description=flamegraph_description, custom_event_ratio=False, color_map=color_map, ) svgfile = GlobalData.local_data + os.sep + flamegraph_filename svgfile = os.path.relpath(svgfile, AnalysisView.template_folder) return svgfile
def get_timelines(job, start, stop): all_stack_data[job].generate_timelines(start, stop) timelines_data = get_timeline_data(all_stack_data[job]) intervals = all_stack_data[job].get_num_timeline_intervals() event_map = GlobalData.loaded_cpu_definition.get_available_event_map( event_to_raw_event=False) timelines_filename = timestamp("timelines.svg") hotspots = all_stack_data[job].get_hotspots(augmented=True) colors = get_top_ten_colours() color_map = {h: colors[hotspots[h]] for h in hotspots} TimeLines( GlobalData.local_data, timelines_data, timelines_filename, intervals, event_map, color_map=color_map, ) svgfile = GlobalData.local_data + os.sep + timelines_filename svgfile = os.path.relpath(svgfile, TraceView.template_folder) return svgfile
def get_barchart(process, hotspots, svg_chart): # Setup Bar Charts event_totals_chart_title = "Total Event Counts for {}: Reference = {}".format( process, process_model.reference_id ) barchart_filename = timestamp("barchart.svg") output_file = GlobalData.local_data + os.sep + barchart_filename chart = svg_chart.generate_vertical_stacked_bar_chart( all_stack_data[process], start=hotspots, title=event_totals_chart_title, output_event_type="original", write_colourmap=True, ) chart.render_to_file(output_file) try: event_totals_table = chart.render_table(style=False, transpose=True, total=True) except Exception as e: event_totals_table = "" svgfile = GlobalData.local_data + os.sep + barchart_filename svgfile = os.path.relpath(svgfile, ProcessView.template_folder) return svgfile, event_totals_table