Skip to content

Commit abe4ca9

Browse files
committed
Updates.
- As Glaze and I have implemented new jump-tables for parsing/serializing and also for running string comparisons. - I've also switched to using my other library BenchMarkSuite for benchmarking implementation.
1 parent c9f9a7d commit abe4ca9

36 files changed

+504208
-472925
lines changed

.github/workflows/CLANG-MacOS.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
run: |
2626
brew install llvm
2727
28+
- name: Install Seaborn
29+
run: |
30+
pip install seaborn
31+
2832
- name: Install Nasm.
2933
run: |
3034
brew install nasm

.github/workflows/GCC-Ubuntu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v4
23+
24+
- name: Install Seaborn
25+
run: |
26+
pip install seaborn
2327
2428
- name: Install the latest gcc compiler.
2529
working-directory: ./

.github/workflows/MSVC-Windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
name: PATH
2828
value: $env:PATH;C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build
2929

30+
- name: Install Seaborn
31+
run: |
32+
pip install seaborn
33+
3034
- name: Configure CMake
3135
working-directory: ./
3236
run: |

CMakeLists.txt

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
cmake_minimum_required(VERSION 3.18)
22

3-
set(CMAKE_CXX_STANDARD 20)
4-
5-
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/Install/")
3+
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/Install/")
64

75
project(
86
"Json-Performance"
97
VERSION "${PRODUCT_VERSION}"
108
LANGUAGES CXX
119
)
1210

11+
set(CMAKE_CXX_STANDARD 20)
12+
1313
include(FetchContent)
14+
include(GetCommitHash.cmake)
1415

1516
FetchContent_Declare(
16-
Jsonifier
17-
GIT_REPOSITORY https://github.com/RealTimeChris/jsonifier.git
17+
jsonifier
18+
GIT_REPOSITORY https://github.com/realtimechris/jsonifier.git
1819
GIT_TAG dev
1920
GIT_SHALLOW TRUE
2021
)
21-
FetchContent_MakeAvailable(Jsonifier)
22+
FetchContent_MakeAvailable(jsonifier)
23+
getCommitHash("${jsonifier_SOURCE_DIR}" JSONIFIER_COMMIT_HASH)
2224

2325
FetchContent_Declare(
2426
glaze
@@ -27,6 +29,16 @@ FetchContent_Declare(
2729
GIT_SHALLOW TRUE
2830
)
2931
FetchContent_MakeAvailable(glaze)
32+
getCommitHash("${glaze_SOURCE_DIR}" GLAZE_COMMIT_HASH)
33+
34+
set(JSONIFIER_LIBRARY "TRUE" CACHE STRING "To avoid circular dependency issues." FORCE)
35+
FetchContent_Declare(
36+
BenchmarkSuite
37+
GIT_REPOSITORY https://github.com/RealTimeChris/BenchmarkSuite.git
38+
GIT_TAG main
39+
GIT_SHALLOW TRUE
40+
)
41+
FetchContent_MakeAvailable(BenchmarkSuite)
3042

3143
FetchContent_Declare(
3244
simdjson
@@ -35,6 +47,7 @@ FetchContent_Declare(
3547
GIT_SHALLOW TRUE
3648
)
3749
FetchContent_MakeAvailable(simdjson)
50+
getCommitHash("${simdjson_SOURCE_DIR}" SIMDJSON_COMMIT_HASH)
3851

3952
add_executable(
4053
"Json-Performance"
@@ -43,7 +56,7 @@ add_executable(
4356

4457
target_link_libraries(
4558
"Json-Performance" PUBLIC
46-
Jsonifier::Jsonifier glaze::glaze simdjson
59+
Jsonifier::Jsonifier glaze::glaze simdjson BenchmarkSuite::BenchmarkSuite
4760
)
4861

4962
target_compile_options(
@@ -63,7 +76,6 @@ target_link_options(
6376
"$<$<CXX_COMPILER_ID:GNU>:$<$<STREQUAL:${ASAN_ENABLED},TRUE>:-fsanitize=address>>"
6477
"$<$<CXX_COMPILER_ID:MSVC>:/DEBUG>"
6578
"$<$<CXX_COMPILER_ID:MSVC>:/OPT:REF>"
66-
"$<$<CXX_COMPILER_ID:MSVC>:/OPT:ICF>"
6779
)
6880

6981
if (WIN32)
@@ -77,14 +89,19 @@ endif()
7789

7890
target_compile_definitions(
7991
"Json-Performance" PUBLIC
80-
"JSON_TEST_PATH=\"${CMAKE_SOURCE_DIR}/Source/ConformanceTests\""
81-
"JSON_PATH=\"${CMAKE_SOURCE_DIR}/Json\""
92+
"JSON_TEST_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Source/ConformanceTests\""
93+
"JSON_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Json\""
8294
"README_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.md\""
95+
"GRAPHS_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/Graphs\""
96+
"BASE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/\""
97+
"JSONIFIER_COMMIT=\"${JSONIFIER_COMMIT_HASH}\""
98+
"SIMDJSON_COMMIT=\"${SIMDJSON_COMMIT_HASH}\""
99+
"GLAZE_COMMIT=\"${GLAZE_COMMIT_HASH}\""
83100
)
84101

85102
install(
86103
FILES
87104
"$<TARGET_FILE:Json-Performance>"
88105
DESTINATION "$<IF:$<CONFIG:Debug>,bin,bin>"
89106
OPTIONAL
90-
)
107+
)

GenerateGraphs.py

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,64 @@
1+
import argparse
12
import json
23
import os
34
import seaborn as sns
45
import matplotlib.pyplot as plt
5-
import pandas as pd
6+
import pandas as pd
7+
import re
68

7-
with open('./Json/Results.json', 'r') as file:
8-
data = json.load(file)
9+
# Set up command-line argument parsing
10+
def parse_args():
11+
parser = argparse.ArgumentParser(description='Process benchmark results from a JSON file.')
12+
parser.add_argument('input_file', type=str, help='Path to the input JSON file')
13+
parser.add_argument('output_directory', type=str, help='Path to the store the graphs')
14+
return parser.parse_args()
915

10-
output_folder = 'Graphs'
11-
os.makedirs(output_folder, exist_ok=True)
16+
def main():
17+
args = parse_args()
18+
input_file = args.input_file
19+
output_folder = args.output_directory
1220

13-
for test in data:
14-
df = pd.DataFrame(test["results"])
21+
with open(input_file, 'r') as file:
22+
data = json.load(file)
1523

16-
sns.set_style("dark")
17-
sns.set_style(rc = {'axes.facecolor': '#0d1117' })
18-
plt.figure(figsize=(10, 6))
19-
ax = plt.gca()
24+
os.makedirs(output_folder, exist_ok=True)
2025

21-
for i, library in enumerate(df["libraryName"].unique()):
22-
library_data = df[df["libraryName"] == library]
23-
for j, result_type in enumerate(library_data["resultType"].unique()):
24-
result_data = library_data[library_data["resultType"] == result_type]
25-
color = result_data["color"].iloc[0]
26-
ax.bar(i + j * 0.2, result_data["resultSpeed"].iloc[0], width=0.2, color=color, label=result_type)
26+
for test in data:
27+
df = pd.DataFrame(test["results"])
2728

28-
ax.set_xticks(range(len(df["libraryName"].unique())))
29-
ax.set_xticklabels(df["libraryName"].unique())
30-
ax.set_title(f'{test["testName"]} Results', color='white')
31-
outside_color = "#0d1117"
32-
ax.set_xlabel('Library Name', color='white')
33-
ax.set_ylabel('Result Speed MB/s', color='white')
29+
sns.set_style("dark")
30+
sns.set_style(rc = {'axes.facecolor': '#0d1117' })
31+
plt.figure(figsize=(10, 6))
32+
ax = plt.gca()
3433

35-
sns.set_theme(style="whitegrid", rc={"axes.edgecolor": outside_color, "xtick.color": outside_color, "ytick.color": outside_color})
36-
plt.gcf().set_facecolor(outside_color)
34+
for i, library in enumerate(df["libraryName"].unique()):
35+
library_data = df[df["libraryName"] == library]
36+
for j, result_type in enumerate(library_data["resultType"].unique()):
37+
result_data = library_data[library_data["resultType"] == result_type]
38+
color = result_data["color"].iloc[0]
39+
ax.bar(i + j * 0.2, result_data["resultSpeed"].iloc[0], width=0.2, color=color, label=result_type)
3740

38-
handles, labels = ax.get_legend_handles_labels()
39-
for text in ax.get_xticklabels() + ax.get_yticklabels():
40-
text.set_color('lightgray')
41+
ax.set_xticks(range(len(df["libraryName"].unique())))
42+
ax.set_xticklabels(df["libraryName"].unique())
43+
ax.set_title(f'{test["testName"]} Results', color='white')
44+
outside_color = "#0d1117"
45+
ax.set_xlabel('Library Name', color='white')
46+
ax.set_ylabel('Result Speed MB/s', color='white')
4147

42-
legend = ax.legend(title='Result Type', loc='best')
48+
sns.set_theme(style="whitegrid", rc={"axes.edgecolor": outside_color, "xtick.color": outside_color, "ytick.color": outside_color})
49+
plt.gcf().set_facecolor(outside_color)
4350

44-
outside_color = "lightgray"
51+
handles, labels = ax.get_legend_handles_labels()
52+
for text in ax.get_xticklabels() + ax.get_yticklabels():
53+
text.set_color('lightgray')
4554

46-
output_file_path = os.path.join(output_folder, f'{test["testName"]}_Results.png')
47-
plt.savefig(output_file_path)
55+
legend = ax.legend(title='Result Type', loc='best')
4856

49-
plt.show()
57+
outside_color = "lightgray"
5058

51-
print('Graphs saved successfully in the "Graphs" folder.')
59+
output_file_path = os.path.join(output_folder, f'{test["testName"]}_Results.png')
60+
plt.savefig(output_file_path)
61+
62+
print('Graphs saved successfully in the "Graphs" folder.')
63+
64+
main()

GetCommitHash.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Define a function to get the short commit hash
2+
function(getCommitHash repo_path commit_var)
3+
execute_process(
4+
COMMAND git -C ${repo_path} rev-parse --short HEAD
5+
OUTPUT_VARIABLE git_commit
6+
OUTPUT_STRIP_TRAILING_WHITESPACE
7+
RESULT_VARIABLE git_result
8+
)
9+
if (git_result EQUAL 0)
10+
set(${commit_var} "${git_commit}" PARENT_SCOPE)
11+
else()
12+
message(FATAL_ERROR "Failed to get the short commit hash from ${repo_path}")
13+
endif()
14+
endfunction()

Json/Abc Test (Minified)-glaze.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Json/Abc Test (Minified)-jsonifier.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Json/Abc Test (Minified)-simdjson.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)