def _custom_chart_heaps_2(trace: ProcessedTrace) -> None: # A different chart for each heap heaps: Sequence[List[_HeapData]] = [[] for _ in range(trace.HeapCount)] prev_non_free_size_after: List[int] = [0 for _ in range(trace.HeapCount)] for gc in trace.gcs: if gc.Generation != Gens.Gen2: continue budget_per_heap = gc.LOHBudgetMB / len(heaps) for hp_i, hp in enumerate(gc.heaps): # Want the difference in size before -- get prev gen2 gc prev_size_after = prev_non_free_size_after[hp_i] gen = hp.gen(Gens.GenLargeObj) size_before_now = gen.non_free_size_before size_after_now = gen.non_free_size_after allocated_bytes = size_before_now - prev_size_after prev_non_free_size_after[hp_i] = size_after_now # gen.budget is before equalizing heaps[hp_i].append( _HeapData( gc_number=gc.Number, budget_mb=budget_per_heap, allocated_mb=bytes_to_mb(allocated_bytes), ) ) # Chart each hp lines = [] for i, hp_data in enumerate(heaps): xs = [d.gc_number for d in hp_data] line0 = BasicLine(name="budget (MB)", xs=xs, ys=[d.budget_mb for d in hp_data]) line1 = BasicLine(name="allocated (MB)", xs=xs, ys=[d.allocated_mb for d in hp_data]) lines.append(BasicLineChart(name=f"hp{i}", lines=(line0, line1))) basic_chart(lines)
def _custom_chart() -> None: xs = tuple(range(8)) basic_chart(( BasicLineChart( lines=( BasicLine(name="linear", xs=xs, ys=xs), BasicLine(name="quadratic", xs=xs, ys=[x**2 for x in xs]), ), x_label="x", y_label="y", ), BasicHistogram(values=[x for n in range(4) for x in repeat(n, n)], x_label="number"), ))