diff --git a/continuous_batching.py b/continuous_batching.py index 6b7c6b6..4abe76f 100644 --- a/continuous_batching.py +++ b/continuous_batching.py @@ -273,37 +273,41 @@ class ContinuousBatching(Scene): self.wait(0.2) # ---- bar config ---- - bar_max_w = 4.5 + bar_max_w = 5.0 bar_h = 0.55 - row_gap = 0.7 + row_gap = 0.8 - # Static Batching row + # ratio: static = baseline (1.0), continuous = 3.4x + ratio = 1.0 / 3.4 + + # ---- Static Batching row ---- s_label = Text("Static Batching", font_size=24, color=RED) s_rect = Rectangle(width=bar_max_w, height=bar_h, color=RED, stroke_width=1.5) - s_bar = Rectangle(width=0, height=bar_h, color=RED, - fill_opacity=0.55, stroke_width=0) \ + s_bar = Rectangle(width=bar_max_w * ratio, height=bar_h, + color=RED, fill_opacity=0.55, stroke_width=0) \ .align_to(s_rect, LEFT).align_to(s_rect, UP) s_num = Text("1.0x", font_size=24, color=RED) - s_row = VGroup(s_label, s_rect, s_bar, s_num) s_label.next_to(s_rect, LEFT, buff=0.4) s_num.next_to(s_rect, RIGHT, buff=0.4) - # Continuous Batching row + # ---- Continuous Batching row ---- c_label = Text("Continuous Batching", font_size=24, color=GREEN) c_rect = Rectangle(width=bar_max_w, height=bar_h, color=GREEN, stroke_width=1.5) - c_bar = Rectangle(width=0, height=bar_h, color=GREEN, - fill_opacity=0.55, stroke_width=0) \ + c_bar = Rectangle(width=bar_max_w, height=bar_h, + color=GREEN, fill_opacity=0.55, stroke_width=0) \ .align_to(c_rect, LEFT).align_to(c_rect, UP) c_num = Text("3.4x", font_size=24, color=GREEN) - c_row = VGroup(c_label, c_rect, c_bar, c_num) c_label.next_to(c_rect, LEFT, buff=0.4) c_num.next_to(c_rect, RIGHT, buff=0.4) - # stack rows, centre - chart = VGroup(s_row, c_row).arrange(DOWN, buff=row_gap, aligned_edge=LEFT) - chart.move_to(ORIGIN).shift(DOWN * 0.25) + # stack rows, centre vertically + chart = VGroup( + VGroup(s_label, s_rect, s_bar, s_num), + VGroup(c_label, c_rect, c_bar, c_num), + ) + chart.arrange(DOWN, buff=row_gap, aligned_edge=LEFT).move_to(ORIGIN) self.play( Create(s_rect), Create(c_rect), @@ -311,11 +315,9 @@ class ContinuousBatching(Scene): ) self.wait(0.3) - # grow static bar + # grow bars self.play(GrowFromEdge(s_bar, LEFT), rate_func=linear, run_time=0.6) self.wait(0.3) - - # grow cb bar self.play(GrowFromEdge(c_bar, LEFT), rate_func=linear, run_time=0.6) self.wait(0.3)