fix: throughput bars — proportional widths (1.0x vs 3.4x), proper GrowFromEdge anim
This commit is contained in:
parent
42c1d5f700
commit
ce2a7c165a
|
|
@ -273,37 +273,41 @@ class ContinuousBatching(Scene):
|
||||||
self.wait(0.2)
|
self.wait(0.2)
|
||||||
|
|
||||||
# ---- bar config ----
|
# ---- bar config ----
|
||||||
bar_max_w = 4.5
|
bar_max_w = 5.0
|
||||||
bar_h = 0.55
|
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_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_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,
|
s_bar = Rectangle(width=bar_max_w * ratio, height=bar_h,
|
||||||
fill_opacity=0.55, stroke_width=0) \
|
color=RED, fill_opacity=0.55, stroke_width=0) \
|
||||||
.align_to(s_rect, LEFT).align_to(s_rect, UP)
|
.align_to(s_rect, LEFT).align_to(s_rect, UP)
|
||||||
s_num = Text("1.0x", font_size=24, color=RED)
|
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_label.next_to(s_rect, LEFT, buff=0.4)
|
||||||
s_num.next_to(s_rect, RIGHT, 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_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_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,
|
c_bar = Rectangle(width=bar_max_w, height=bar_h,
|
||||||
fill_opacity=0.55, stroke_width=0) \
|
color=GREEN, fill_opacity=0.55, stroke_width=0) \
|
||||||
.align_to(c_rect, LEFT).align_to(c_rect, UP)
|
.align_to(c_rect, LEFT).align_to(c_rect, UP)
|
||||||
c_num = Text("3.4x", font_size=24, color=GREEN)
|
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_label.next_to(c_rect, LEFT, buff=0.4)
|
||||||
c_num.next_to(c_rect, RIGHT, buff=0.4)
|
c_num.next_to(c_rect, RIGHT, buff=0.4)
|
||||||
|
|
||||||
# stack rows, centre
|
# stack rows, centre vertically
|
||||||
chart = VGroup(s_row, c_row).arrange(DOWN, buff=row_gap, aligned_edge=LEFT)
|
chart = VGroup(
|
||||||
chart.move_to(ORIGIN).shift(DOWN * 0.25)
|
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(
|
self.play(
|
||||||
Create(s_rect), Create(c_rect),
|
Create(s_rect), Create(c_rect),
|
||||||
|
|
@ -311,11 +315,9 @@ class ContinuousBatching(Scene):
|
||||||
)
|
)
|
||||||
self.wait(0.3)
|
self.wait(0.3)
|
||||||
|
|
||||||
# grow static bar
|
# grow bars
|
||||||
self.play(GrowFromEdge(s_bar, LEFT), rate_func=linear, run_time=0.6)
|
self.play(GrowFromEdge(s_bar, LEFT), rate_func=linear, run_time=0.6)
|
||||||
self.wait(0.3)
|
self.wait(0.3)
|
||||||
|
|
||||||
# grow cb bar
|
|
||||||
self.play(GrowFromEdge(c_bar, LEFT), rate_func=linear, run_time=0.6)
|
self.play(GrowFromEdge(c_bar, LEFT), rate_func=linear, run_time=0.6)
|
||||||
self.wait(0.3)
|
self.wait(0.3)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue