MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
benchmark_graph_scale2 Namespace Reference

Functions

None add_bar_label (plt.Axes axis, float value, float y_position)
None main ()

Variables

 EIGEN_TIMES_MS
 NATIVE_TIMES_MS
list POINT_COLORS = [TEXT_COLOR, "#52D6FF", "#92FFE8"]
 VULKAN_TIMES_MS

Function Documentation

◆ add_bar_label()

None add_bar_label ( plt.Axes axis,
float value,
float y_position )

Definition at line 37 of file benchmark_graph_scale2.py.

37def add_bar_label(axis: plt.Axes, value: float, y_position: float) -> None:
38 axis.text(
39 value + 35,
40 y_position,
41 f"{value:,.1f} ms",
42 va="center",
43 color=TEXT_COLOR,
44 fontsize=17,
45 fontweight="bold",
46 )
47
48

◆ main()

None main ( void )

Definition at line 49 of file benchmark_graph_scale2.py.

49def main() -> None:
50 samples = [NATIVE_TIMES_MS, EIGEN_TIMES_MS, VULKAN_TIMES_MS]
51 previous_samples = [
52 PREVIOUS_NATIVE_TIMES_MS,
53 PREVIOUS_EIGEN_TIMES_MS,
54 PREVIOUS_VULKAN_TIMES_MS,
55 ]
56 means = np.array([values.mean() for values in samples])
57 previous_means = np.array([values.mean() for values in previous_samples])
58 fps = FRAME_COUNT / (means / 1000.0)
59 scale_cost = (means - previous_means) / previous_means * 100.0
60
61 eigen_reduction = (means[0] - means[1]) / means[0] * 100.0
62 vulkan_reduction = (means[0] - means[2]) / means[0] * 100.0
63 vulkan_speedup = means[0] / means[2]
64
65 figure = plt.figure(figsize=(12, 6.75), dpi=100, facecolor=BACKGROUND_COLOR)
66 axis = figure.add_axes((0.14, 0.24, 0.77, 0.46), facecolor=PANEL_COLOR)
67
68 figure.text(
69 0.07,
70 0.91,
71 f"Pixel-heavy sphere: Vulkan is {vulkan_speedup:.1f}× faster",
72 color=TEXT_COLOR,
73 fontsize=28,
74 fontweight="bold",
75 )
76 figure.text(
77 0.07,
78 0.845,
79 "Scale 2.0 • 65,024 triangles • 320×180 framebuffer • 600 frames • 5-run average",
80 color=MUTED_TEXT_COLOR,
81 fontsize=15,
82 )
83
84 y_positions = [2, 1, 0]
85 axis.barh(
86 y_positions,
87 means,
88 height=0.48,
89 color=[NATIVE_COLOR, EIGEN_COLOR, VULKAN_COLOR],
90 edgecolor="none",
91 zorder=2,
92 )
93
94 point_offsets = np.linspace(-0.14, 0.14, len(NATIVE_TIMES_MS))
95 for values, y_position, point_color in zip(
96 samples, y_positions, POINT_COLORS, strict=True
97 ):
98 axis.scatter(
99 values,
100 y_position + point_offsets,
101 s=42,
102 color=point_color,
103 edgecolor=BACKGROUND_COLOR,
104 linewidth=1.2,
105 zorder=3,
106 )
107
108 for mean, y_position in zip(means, y_positions, strict=True):
109 add_bar_label(axis, float(mean), y_position)
110
111 axis.set_xlim(0, 5100)
112 axis.set_ylim(-0.55, 2.55)
113 axis.set_yticks(y_positions, ["Native CPU", "Eigen CPU", "Vulkan GPU"])
114 axis.set_xlabel(
115 "Average time for 600 frames (lower is better)",
116 color=MUTED_TEXT_COLOR,
117 fontsize=13,
118 labelpad=12,
119 )
120 axis.tick_params(axis="x", colors=MUTED_TEXT_COLOR, labelsize=11)
121 axis.tick_params(axis="y", colors=TEXT_COLOR, labelsize=16, length=0, pad=12)
122 axis.xaxis.grid(True, color=GRID_COLOR, linewidth=1, alpha=0.65)
123 axis.set_axisbelow(True)
124 for spine in axis.spines.values():
125 spine.set_visible(False)
126
127 figure.text(
128 0.07,
129 0.11,
130 f"Native {fps[0]:,.0f} FPS • Eigen {fps[1]:,.0f} FPS • Vulkan {fps[2]:,.0f} FPS",
131 color=TEXT_COLOR,
132 fontsize=14,
133 fontweight="bold",
134 )
135 figure.text(
136 0.07,
137 0.055,
138 f"10× scale cost: Native {scale_cost[0]:+.1f}% • Eigen {scale_cost[1]:+.1f}% • Vulkan {scale_cost[2]:+.1f}%",
139 color=MUTED_TEXT_COLOR,
140 fontsize=13,
141 )
142 figure.text(
143 0.93,
144 0.055,
145 f"Eigen saves {eigen_reduction:.1f}% • Vulkan saves {vulkan_reduction:.1f}%",
146 color=VULKAN_COLOR,
147 fontsize=13,
148 fontweight="bold",
149 ha="right",
150 )
151
152 output_path = Path(__file__).with_name(
153 "benchmark_obj_backends_scale2_pixel_heavy.png"
154 )
155 figure.savefig(output_path, dpi=160, facecolor=figure.get_facecolor())
156 plt.close(figure)
157
158 print(f"Native mean: {means[0]:.3f} ms ({fps[0]:.1f} FPS)")
159 print(f"Eigen mean: {means[1]:.3f} ms ({fps[1]:.1f} FPS)")
160 print(f"Vulkan mean: {means[2]:.3f} ms ({fps[2]:.1f} FPS)")
161 print(f"Eigen vs native: {eigen_reduction:.3f}% less time")
162 print(
163 f"Vulkan vs native: {vulkan_reduction:.3f}% less time "
164 f"({vulkan_speedup:.3f}x faster)"
165 )
166 print(
167 "Scale 0.2 to 2.0 timing change: "
168 f"native {scale_cost[0]:+.3f}%, "
169 f"Eigen {scale_cost[1]:+.3f}%, "
170 f"Vulkan {scale_cost[2]:+.3f}%"
171 )
172 print(output_path)
173
174
Definition main.py:1

Variable Documentation

◆ EIGEN_TIMES_MS

benchmark_graph_scale2.EIGEN_TIMES_MS
Initial value:
= np.array(
[4308.499611, 4332.886647, 4330.142051, 4330.850781, 4322.548658]
)

Definition at line 27 of file benchmark_graph_scale2.py.

◆ NATIVE_TIMES_MS

benchmark_graph_scale2.NATIVE_TIMES_MS
Initial value:
= np.array(
[4466.856635, 4471.570342, 4473.393354, 4475.139095, 4472.841865]
)

Definition at line 24 of file benchmark_graph_scale2.py.

◆ POINT_COLORS

list benchmark_graph_scale2.POINT_COLORS = [TEXT_COLOR, "#52D6FF", "#92FFE8"]

Definition at line 34 of file benchmark_graph_scale2.py.

◆ VULKAN_TIMES_MS

benchmark_graph_scale2.VULKAN_TIMES_MS
Initial value:
= np.array(
[217.024511, 217.555523, 218.379073, 218.838467, 215.628848]
)

Definition at line 30 of file benchmark_graph_scale2.py.