Skip to content

Commit 07136a9

Browse files
committed
Adding more convenience functions.
1 parent e5197d5 commit 07136a9

File tree

461 files changed

+32039
-6210407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+32039
-6210407
lines changed

.github/workflows/Benchmark.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- main
8-
- benchmarking
7+
- benchmarking-new
98

109
jobs:
1110
Build-MSVC-Windows:
@@ -332,17 +331,17 @@ jobs:
332331
sudo git config --global user.email "[email protected]"
333332
sudo git config --global user.name "RealTimeChris"
334333
sudo git fetch origin
335-
sudo git checkout benchmarking
336-
sudo git pull -f origin benchmarking
337-
sudo git merge origin/temp-msvc-windows --no-ff --allow-unrelated-histories
338-
sudo git merge origin/temp-gnucxx-ubuntu --no-ff --allow-unrelated-histories
339-
sudo git merge origin/temp-clang-ubuntu --no-ff --allow-unrelated-histories
340-
sudo git merge origin/temp-gnucxx-macos --no-ff --allow-unrelated-histories
341-
sudo git merge origin/temp-clang-macos --no-ff --allow-unrelated-histories
334+
sudo git config pull.ff only
335+
sudo git checkout benchmarking-new
336+
sudo git pull -f origin benchmarking-new
337+
sudo git merge origin/temp-msvc-windows --no-ff
338+
sudo git merge origin/temp-gnucxx-ubuntu --no-ff
339+
sudo git merge origin/temp-clang-ubuntu --no-ff
340+
sudo git merge origin/temp-gnucxx-macos --no-ff
341+
sudo git merge origin/temp-clang-macos --no-ff
342342
sudo git checkout --orphan newBranch
343343
sudo git add .
344344
sudo git commit -m "Updating necessary files."
345-
sudo git branch -D benchmarking
346345
sudo git branch -m benchmarking
347346
sudo git push origin benchmarking -f
348347

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ target_link_libraries(
6363
target_compile_options(
6464
"Json-Performance" PUBLIC
6565
"$<$<CXX_COMPILER_ID:MSVC>:$<$<STREQUAL:${ASAN_ENABLED},TRUE>:/fsanitize=address>>"
66+
"$<$<CXX_COMPILER_ID:CLANG>:-Wpedantic>"
67+
"$<$<CXX_COMPILER_ID:GNU>:-Wpedantic>"
6668
"$<$<CXX_COMPILER_ID:CLANG>:-Wextra>"
6769
"$<$<CXX_COMPILER_ID:CLANG>:-Wall>"
6870
"$<$<CXX_COMPILER_ID:GNU>:-Wextra>"
6971
"$<$<CXX_COMPILER_ID:MSVC>:/Wall>"
7072
"$<$<CXX_COMPILER_ID:GNU>:-Wall>"
73+
"$<$<CXX_COMPILER_ID:MSVC>:/W4>"
7174
)
7275

7376
target_link_options(
@@ -86,15 +89,10 @@ endif()
8689

8790
target_compile_definitions(
8891
"Json-Performance" PUBLIC
89-
"JSON_TEST_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Source/\""
90-
"JSON_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Json\""
91-
"README_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/\""
92-
"GRAPHS_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Graphs\""
93-
"BASE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/\""
92+
"BASE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}\""
9493
"JSONIFIER_COMMIT=\"${JSONIFIER_COMMIT_HASH}\""
9594
"SIMDJSON_COMMIT=\"${SIMDJSON_COMMIT_HASH}\""
9695
"GLAZE_COMMIT=\"${GLAZE_COMMIT_HASH}\""
97-
"GIT_BRANCH=\"${GIT_BRANCH}\""
9896
"OPERATING_SYSTEM_NAME=\"${CMAKE_SYSTEM_NAME}\""
9997
"OPERATING_SYSTEM_VERSION=\"${CMAKE_SYSTEM_VERSION}\""
10098
"COMPILER_ID=\"${CMAKE_CXX_COMPILER_ID}\""

GenerateGraphs.py

Lines changed: 74 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -56,66 +56,26 @@ def calculate_cumulative_speedup(df):
5656

5757
return cumulative_speedups
5858

59-
def plot_cumulative_speedup(df, cumulative_speedups, output_folder, test_name):
60-
sns.set_style("dark")
61-
sns.set_style(rc={'axes.facecolor': '#0d1117'})
62-
plt.figure(figsize=(10, 6))
63-
ax = plt.gca()
64-
65-
sns.set_theme(style="whitegrid", rc={"axes.edgecolor": "#0d1117", "xtick.color": "#0d1117", "ytick.color": "#0d1117"})
66-
plt.gcf().set_facecolor("#0d1117")
67-
ax = plt.gca()
68-
69-
sorted_df = df.sort_values(by="resultSpeed", ascending=False)
70-
71-
library_colors = {}
72-
for _, row in sorted_df.iterrows():
73-
library_colors[(row['libraryName'], row['resultType'])] = row['color']
74-
75-
libraries = sorted_df["libraryName"].unique()
76-
77-
cumulative_speedup_read = cumulative_speedups.get("Read", [0] * len(libraries))
78-
cumulative_speedup_write = cumulative_speedups.get("Write", [0] * len(libraries))
79-
80-
num_libraries = len(libraries)
81-
max_libraries = max(2, num_libraries)
82-
width = 0.8 / max_libraries
83-
84-
for i, library in enumerate(libraries):
85-
read_speedup = cumulative_speedup_read[i] if i < len(cumulative_speedup_read) else 0
86-
write_speedup = cumulative_speedup_write[i] if i < len(cumulative_speedup_write) else 0
87-
88-
read_color = library_colors.get((library, 'Read'), 'gray')
89-
write_color = library_colors.get((library, 'Write'), 'gray')
90-
91-
font_size = max(8, width * 30)
92-
if read_speedup != 0:
93-
read_bar = ax.bar(i - width / 2, read_speedup, label=f"{library} Read", color=read_color, width=width)
94-
ax.text(i - width / 2, read_speedup - read_speedup * 0.05,
95-
f"{read_speedup:.2f}%", ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
96-
97-
if write_speedup != 0:
98-
write_bar = ax.bar(i + width / 2, write_speedup, label=f"{library} Write", color=write_color, width=width)
99-
ax.text(i + width / 2, write_speedup - write_speedup * 0.05,
100-
f"{write_speedup:.2f}%", ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
101-
102-
ax.set_xticks(range(len(libraries)))
103-
ax.set_xticklabels(libraries)
104-
ax.set_title(f'{test_name} Cumulative Speedup (Relative to Slowest Library)', color='white')
105-
ax.set_xlabel('Library Name', color='white')
106-
ax.set_ylabel('Cumulative Speedup (%)', color='white')
107-
108-
handles, labels = ax.get_legend_handles_labels()
109-
for text in ax.get_xticklabels() + ax.get_yticklabels():
110-
text.set_color('lightgray')
111-
112-
ax.legend(title='Library and Result Type', loc='best')
113-
114-
output_file_path_speedup = os.path.join(output_folder, f'{test_name}_Cumulative_Speedup.png')
115-
plt.savefig(output_file_path_speedup)
116-
plt.close()
117-
118-
def plot_raw_comparisons(df, raw_speeds, output_folder, test_name):
59+
def plot_speed_results(
60+
df,
61+
speed_data,
62+
output_folder,
63+
test_name,
64+
is_cumulative=False,
65+
y_label="Result Speed (MB/s)",
66+
label_metric = "MB/s"
67+
):
68+
"""
69+
Plots either cumulative speedups or raw speed comparisons for libraries.
70+
71+
Args:
72+
df (pd.DataFrame): The DataFrame containing library performance data.
73+
speed_data (dict): The speed data, with keys "Read" and "Write".
74+
output_folder (str): Path to the folder where the plot will be saved.
75+
test_name (str): Name of the test for labeling the output.
76+
is_cumulative (bool): If True, plots cumulative speedups; otherwise, raw speeds.
77+
y_label (str): Label for the y-axis.
78+
"""
11979
sns.set_style("dark")
12080
sns.set_style(rc={'axes.facecolor': '#0d1117'})
12181
plt.figure(figsize=(10, 6))
@@ -125,54 +85,71 @@ def plot_raw_comparisons(df, raw_speeds, output_folder, test_name):
12585
plt.gcf().set_facecolor("#0d1117")
12686
ax = plt.gca()
12787

128-
sorted_df = df.sort_values(by="resultSpeed", ascending=False)
88+
has_read_results = "Read" in df["resultType"].unique()
89+
has_write_results = "Write" in df["resultType"].unique()
90+
91+
if has_read_results:
92+
sort_df = df[df["resultType"] == "Read"].sort_values(by="resultSpeed", ascending=False)
93+
elif has_write_results:
94+
sort_df = df[df["resultType"] == "Write"].sort_values(by="resultSpeed", ascending=False)
95+
else:
96+
print("No read or write results found in the DataFrame.")
97+
return
12998

130-
library_colors = {}
131-
for _, row in sorted_df.iterrows():
132-
library_colors[(row['libraryName'], row['resultType'])] = row['color']
99+
sorted_libraries = sort_df["libraryName"].tolist()
133100

134-
libraries = sorted_df["libraryName"].unique()
101+
library_colors = {
102+
(row['libraryName'], row['resultType']): row['color']
103+
for _, row in df.iterrows()
104+
}
135105

136-
cumulative_speedup_read = raw_speeds.get("Read", [0] * len(libraries))
137-
cumulative_speedup_write = raw_speeds.get("Write", [0] * len(libraries))
106+
speed_read = speed_data.get("Read", [0] * len(sorted_libraries))
107+
speed_write = speed_data.get("Write", [0] * len(sorted_libraries))
138108

139-
num_libraries = len(libraries)
109+
num_libraries = len(sorted_libraries)
140110
max_libraries = max(2, num_libraries)
141111
width = 0.8 / max_libraries
142112

143-
for i, library in enumerate(libraries):
144-
read_speedup = cumulative_speedup_read[i] if i < len(cumulative_speedup_read) else 0
145-
write_speedup = cumulative_speedup_write[i] if i < len(cumulative_speedup_write) else 0
113+
for i, library in enumerate(sorted_libraries):
114+
read_speed = speed_read[i] if i < len(speed_read) else 0
115+
write_speed = speed_write[i] if i < len(speed_write) else 0
146116

147117
read_color = library_colors.get((library, 'Read'), 'gray')
148118
write_color = library_colors.get((library, 'Write'), 'gray')
149-
font_size = max(8, width * 30)
150-
151-
if read_speedup != 0:
152-
read_bar = ax.bar(i - width / 2, read_speedup, label=f"{library} Read", color=read_color, width=width)
153-
ax.text(i - width / 2, read_speedup - read_speedup * 0.05,
154-
f"{read_speedup:.2f}MB/s", ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
155-
156-
if write_speedup != 0:
157-
write_bar = ax.bar(i + width / 2, write_speedup, label=f"{library} Write", color=write_color, width=width)
158-
ax.text(i + width / 2, write_speedup - write_speedup * 0.05,
159-
f"{write_speedup:.2f}MB/s", ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
160119

120+
font_size = max(8, width * 30)
161121

162-
ax.set_xticks(range(len(libraries)))
163-
ax.set_xticklabels(libraries)
164-
ax.set_title(f'{test_name} Result Speed Comparison', color='white')
122+
if read_speed != 0 and write_speed != 0:
123+
ax.bar(i - width / 2, read_speed, label=f"{library} Read", color=read_color, width=width)
124+
ax.bar(i + width / 2, write_speed, label=f"{library} Write", color=write_color, width=width)
125+
elif read_speed != 0:
126+
ax.bar(i, read_speed, label=f"{library} Read", color=read_color, width=width)
127+
elif write_speed != 0:
128+
ax.bar(i, write_speed, label=f"{library} Write", color=write_color, width=width)
129+
130+
if read_speed != 0:
131+
ax.text(i - width / 2 if write_speed != 0 else i, read_speed - 0.05 * read_speed,
132+
f"{read_speed:.2f}"+label_metric, ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
133+
if write_speed != 0:
134+
ax.text(i + width / 2 if read_speed != 0 else i, write_speed - 0.05 * write_speed,
135+
f"{write_speed:.2f}"+label_metric, ha='center', va='top', color='black', fontsize=font_size, fontweight='bold')
136+
137+
ax.set_xticks(range(len(sorted_libraries)))
138+
ax.set_xticklabels(sorted_libraries, ha='center')
139+
ax.set_title(
140+
f"{test_name} {'Cumulative Speedup (Relative to Slowest Library)' if is_cumulative else 'Result Speed Comparison'}",
141+
color='white'
142+
)
165143
ax.set_xlabel('Library Name', color='white')
166-
ax.set_ylabel('Result Speed (MB/s)', color='white')
167-
168-
handles, labels = ax.get_legend_handles_labels()
144+
ax.set_ylabel(y_label, color='white')
145+
169146
for text in ax.get_xticklabels() + ax.get_yticklabels():
170147
text.set_color('lightgray')
171-
148+
172149
ax.legend(title='Library and Result Type', loc='best')
173-
174-
output_file_path_speedup = os.path.join(output_folder, f'{test_name}_Results.png')
175-
plt.savefig(output_file_path_speedup)
150+
151+
output_file_path = os.path.join(output_folder, f"{test_name}_{'Cumulative_Speedup' if is_cumulative else 'Results'}.png")
152+
plt.savefig(output_file_path)
176153
plt.close()
177154

178155
def main():
@@ -191,11 +168,11 @@ def main():
191168
raw_speed = get_raw_speeds(df)
192169

193170
cumulative_speedups = calculate_cumulative_speedup(df)
194-
195-
plot_raw_comparisons(df, raw_speed , output_folder, test["testName"])
196-
197-
plot_cumulative_speedup(df, cumulative_speedups, output_folder, test["testName"])
198-
171+
172+
plot_speed_results(df, raw_speed, output_folder, test["testName"], is_cumulative = False, y_label = "Result Speed (MB/s)")
173+
174+
plot_speed_results(df, cumulative_speedups, output_folder, test["testName"], is_cumulative = True, y_label = "Cumulative Speedup (%)", label_metric="%")
175+
199176
print(f'Graphs saved successfully for {test["testName"]}!')
200177

201178
if __name__ == "__main__":
-45.4 KB
Binary file not shown.
-45.8 KB
Binary file not shown.
-45.4 KB
Binary file not shown.
-45.6 KB
Binary file not shown.
Binary file not shown.
-46.3 KB
Binary file not shown.
-46.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)