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 Namespace Reference

Functions

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

Variables

str ACCENT_COLOR = "#52D6FF"
str BACKGROUND_COLOR = "#071525"
str EIGEN_COLOR = "#1185FE"
 EIGEN_TIMES_MS
int FRAME_COUNT = 600
str GRID_COLOR = "#294158"
str MUTED_TEXT_COLOR = "#A9C0D5"
str NATIVE_COLOR = "#7D93A8"
 NATIVE_TIMES_MS
str PANEL_COLOR = "#0D2238"
list POINT_COLORS = [TEXT_COLOR, "#52D6FF", "#92FFE8"]
str TEXT_COLOR = "#F5F9FF"
str VULKAN_COLOR = "#00C9A7"
 VULKAN_TIMES_MS

Function Documentation

◆ add_bar_label() [1/2]

None add_bar_label ( axis,
float value,
float y_position )

Definition at line 23 of file benchmark_graph.py.

23def add_bar_label(axis, value: float, y_position: float) -> None:
24 axis.text(
25 value + 18,
26 y_position,
27 f"{value:,.1f} ms",
28 va="center",
29 color=TEXT_COLOR,
30 fontsize=18,
31 fontweight="bold",
32 )
33
34

◆ add_bar_label() [2/2]

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

Definition at line 31 of file benchmark_graph.py.

31def add_bar_label(axis: plt.Axes, value: float, y_position: float) -> None:
32 axis.text(
33 value + 20,
34 y_position,
35 f"{value:,.1f} ms",
36 va="center",
37 color=TEXT_COLOR,
38 fontsize=17,
39 fontweight="bold",
40 )
41
42

◆ main()

None main ( void )

Definition at line 43 of file benchmark_graph.py.

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

Variable Documentation

◆ ACCENT_COLOR

str benchmark_graph.ACCENT_COLOR = "#52D6FF"

Definition at line 20 of file benchmark_graph.py.

◆ BACKGROUND_COLOR

str BACKGROUND_COLOR = "#071525"

Definition at line 20 of file benchmark_graph.py.

◆ EIGEN_COLOR

str EIGEN_COLOR = "#1185FE"

Definition at line 26 of file benchmark_graph.py.

◆ EIGEN_TIMES_MS

benchmark_graph.EIGEN_TIMES_MS
Initial value:
= np.array(
[3175.934356, 3108.612292, 3148.424937, 3155.347637, 3161.096880]
)

Definition at line 12 of file benchmark_graph.py.

◆ FRAME_COUNT

int FRAME_COUNT = 600

Definition at line 18 of file benchmark_graph.py.

◆ GRID_COLOR

str GRID_COLOR = "#294158"

Definition at line 24 of file benchmark_graph.py.

◆ MUTED_TEXT_COLOR

str MUTED_TEXT_COLOR = "#A9C0D5"

Definition at line 23 of file benchmark_graph.py.

◆ NATIVE_COLOR

str NATIVE_COLOR = "#7D93A8"

Definition at line 25 of file benchmark_graph.py.

◆ NATIVE_TIMES_MS

benchmark_graph.NATIVE_TIMES_MS
Initial value:
= np.array(
[3214.698109, 3232.651315, 3243.059780, 3197.778456, 3248.197693]
)

Definition at line 9 of file benchmark_graph.py.

◆ PANEL_COLOR

str PANEL_COLOR = "#0D2238"

Definition at line 21 of file benchmark_graph.py.

◆ POINT_COLORS

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

Definition at line 28 of file benchmark_graph.py.

◆ TEXT_COLOR

str TEXT_COLOR = "#F5F9FF"

Definition at line 22 of file benchmark_graph.py.

◆ VULKAN_COLOR

str benchmark_graph.VULKAN_COLOR = "#00C9A7"

Definition at line 27 of file benchmark_graph.py.

◆ VULKAN_TIMES_MS

benchmark_graph.VULKAN_TIMES_MS
Initial value:
= np.array(
[215.720986, 214.006995, 220.344958, 224.275982, 216.000173]
)

Definition at line 15 of file benchmark_graph.py.