ssrjson-benchmark 0.0.1rc2__cp39-cp39-win_amd64.whl → 0.0.3__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ssrjson-benchmark might be problematic. Click here for more details.
- ssrjson_benchmark/_ssrjson_benchmark.pyd +0 -0
- ssrjson_benchmark/benchmark_main.py +36 -28
- ssrjson_benchmark/template.md +1 -0
- {ssrjson_benchmark-0.0.1rc2.dist-info → ssrjson_benchmark-0.0.3.dist-info}/METADATA +25 -3
- {ssrjson_benchmark-0.0.1rc2.dist-info → ssrjson_benchmark-0.0.3.dist-info}/RECORD +8 -8
- {ssrjson_benchmark-0.0.1rc2.dist-info → ssrjson_benchmark-0.0.3.dist-info}/WHEEL +0 -0
- {ssrjson_benchmark-0.0.1rc2.dist-info → ssrjson_benchmark-0.0.3.dist-info}/licenses/LICENSE +0 -0
- {ssrjson_benchmark-0.0.1rc2.dist-info → ssrjson_benchmark-0.0.3.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -18,6 +18,7 @@ import matplotlib.pyplot as plt
|
|
|
18
18
|
import matplotlib as mpl
|
|
19
19
|
|
|
20
20
|
import orjson
|
|
21
|
+
import ujson
|
|
21
22
|
import ssrjson
|
|
22
23
|
|
|
23
24
|
|
|
@@ -44,37 +45,46 @@ PDF_HEADING_FONT = "Helvetica-Bold"
|
|
|
44
45
|
PDF_TEXT_FONT = "Courier"
|
|
45
46
|
|
|
46
47
|
# baseline is the first one.
|
|
47
|
-
LIBRARIES_COLORS = {
|
|
48
|
+
LIBRARIES_COLORS = {
|
|
49
|
+
"json": "#74c476",
|
|
50
|
+
"ujson": "#c994c7",
|
|
51
|
+
"orjson": "#2c7fb8",
|
|
52
|
+
"ssrjson": "#fd8d3c",
|
|
53
|
+
}
|
|
48
54
|
LIBRARIES: dict[str, dict[str, Callable[[str | bytes], Any]]] = {
|
|
49
55
|
"dumps": {
|
|
50
56
|
"json.dumps": json.dumps,
|
|
57
|
+
"ujson.dumps": ujson.dumps,
|
|
51
58
|
"orjson.dumps+decode": lambda x: orjson.dumps(x).decode("utf-8"),
|
|
52
59
|
"ssrjson.dumps": ssrjson.dumps,
|
|
53
60
|
},
|
|
54
61
|
"dumps(indented2)": {
|
|
55
62
|
"json.dumps": lambda x: json.dumps(x, indent=2),
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
).decode("utf-8"),
|
|
63
|
+
"ujson.dumps+decode": lambda x: ujson.dumps(x, indent=2),
|
|
64
|
+
"orjson.dumps": lambda x: orjson.dumps(x, option=orjson.OPT_INDENT_2),
|
|
59
65
|
"ssrjson.dumps": lambda x: ssrjson.dumps(x, indent=2),
|
|
60
66
|
},
|
|
61
67
|
"dumps_to_bytes": {
|
|
62
68
|
"json.dumps+encode": lambda x: json.dumps(x).encode("utf-8"),
|
|
69
|
+
"ujson.dumps_to_bytes": lambda x: ujson.dumps(x).encode("utf-8"),
|
|
63
70
|
"orjson.dumps": orjson.dumps,
|
|
64
71
|
"ssrjson.dumps_to_bytes": ssrjson.dumps_to_bytes,
|
|
65
72
|
},
|
|
66
73
|
"dumps_to_bytes(indented2)": {
|
|
67
74
|
"json.dumps+encode": lambda x: json.dumps(x, indent=2).encode("utf-8"),
|
|
75
|
+
"ujson.dumps_to_bytes": lambda x: ujson.dumps(x, indent=2).encode("utf-8"),
|
|
68
76
|
"orjson.dumps": lambda x: orjson.dumps(x, option=orjson.OPT_INDENT_2),
|
|
69
77
|
"ssrjson.dumps_to_bytes": lambda x: ssrjson.dumps_to_bytes(x, indent=2),
|
|
70
78
|
},
|
|
71
79
|
"loads(str)": {
|
|
72
80
|
"json.loads": json.loads,
|
|
81
|
+
"ujson.loads": ujson.loads,
|
|
73
82
|
"orjson.loads": orjson.loads,
|
|
74
83
|
"ssrjson.loads": ssrjson.loads,
|
|
75
84
|
},
|
|
76
85
|
"loads(bytes)": {
|
|
77
86
|
"json.loads": json.loads,
|
|
87
|
+
"ujson.loads": ujson.loads,
|
|
78
88
|
"orjson.loads": orjson.loads,
|
|
79
89
|
"ssrjson.loads": ssrjson.loads,
|
|
80
90
|
},
|
|
@@ -357,7 +367,7 @@ def plot_relative_ops(data: dict, doc_name: str, index_s: str) -> io.BytesIO:
|
|
|
357
367
|
|
|
358
368
|
for ax, cat in zip(axs, CATEGORIES):
|
|
359
369
|
vals = [1.0] + [data[cat][f"{name}_{index_s}_ratio"] for name in libs[1:]]
|
|
360
|
-
gbps = (data[cat]["ssrjson_bytes_per_sec"]
|
|
370
|
+
gbps = (data[cat]["ssrjson_bytes_per_sec"]) / (1024**3)
|
|
361
371
|
|
|
362
372
|
for xi, val, col in zip(x_positions, vals, colors):
|
|
363
373
|
ax.bar(xi, val, width=bar_width, color=col)
|
|
@@ -375,7 +385,7 @@ def plot_relative_ops(data: dict, doc_name: str, index_s: str) -> io.BytesIO:
|
|
|
375
385
|
ax.text(
|
|
376
386
|
x_positions[ssrjson_index],
|
|
377
387
|
vals[ssrjson_index] / 2,
|
|
378
|
-
f"{gbps:.2f}
|
|
388
|
+
f"{gbps:.2f} GB/s",
|
|
379
389
|
ha="center",
|
|
380
390
|
va="center",
|
|
381
391
|
fontsize=10,
|
|
@@ -557,6 +567,22 @@ def generate_pdf_report(
|
|
|
557
567
|
return output_pdf_path
|
|
558
568
|
|
|
559
569
|
|
|
570
|
+
def fetch_header(rev) -> str:
|
|
571
|
+
with open(os.path.join(CUR_DIR, "template.md"), "r") as f:
|
|
572
|
+
template = f.read()
|
|
573
|
+
return template.format(
|
|
574
|
+
REV=rev,
|
|
575
|
+
TIME=time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()),
|
|
576
|
+
OS=f"{platform.system()} {platform.machine()} {platform.release()} {platform.version()}",
|
|
577
|
+
PYTHON=sys.version,
|
|
578
|
+
ORJSON_VER=orjson.__version__,
|
|
579
|
+
UJSON_VER=ujson.__version__,
|
|
580
|
+
SIMD_FLAGS=ssrjson.get_current_features(),
|
|
581
|
+
CHIPSET=get_cpu_name(),
|
|
582
|
+
MEM=get_mem_total(),
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
|
|
560
586
|
def generate_report(result: dict[str, dict[str, Any]], file: str, out_dir: str = CWD):
|
|
561
587
|
file = file.removesuffix(".json")
|
|
562
588
|
report_name = f"{file}.pdf"
|
|
@@ -576,17 +602,8 @@ def generate_report(result: dict[str, dict[str, Any]], file: str, out_dir: str =
|
|
|
576
602
|
)
|
|
577
603
|
figures.append(tmp)
|
|
578
604
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
template = template.format(
|
|
582
|
-
REV=file.removeprefix("benchmark_result_").removesuffix(".json"),
|
|
583
|
-
TIME=time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()),
|
|
584
|
-
OS=f"{platform.system()} {platform.machine()} {platform.release()} {platform.version()}",
|
|
585
|
-
PYTHON=sys.version,
|
|
586
|
-
ORJSON_VER=orjson.__version__,
|
|
587
|
-
SIMD_FLAGS=ssrjson.get_current_features(),
|
|
588
|
-
CHIPSET=get_cpu_name(),
|
|
589
|
-
MEM=get_mem_total(),
|
|
605
|
+
template = fetch_header(
|
|
606
|
+
file.removeprefix("benchmark_result_").removesuffix(".json")
|
|
590
607
|
)
|
|
591
608
|
out_path = generate_pdf_report(
|
|
592
609
|
figures,
|
|
@@ -607,17 +624,8 @@ def generate_report_markdown(
|
|
|
607
624
|
if not os.path.exists(report_folder):
|
|
608
625
|
os.makedirs(report_folder)
|
|
609
626
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
template = template.format(
|
|
613
|
-
REV=file.removeprefix("benchmark_result_").removesuffix(".json"),
|
|
614
|
-
TIME=time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()),
|
|
615
|
-
OS=f"{platform.system()} {platform.machine()} {platform.release()} {platform.version()}",
|
|
616
|
-
PYTHON=sys.version,
|
|
617
|
-
ORJSON_VER=orjson.__version__,
|
|
618
|
-
SIMD_FLAGS=ssrjson.get_current_features(),
|
|
619
|
-
CHIPSET=get_cpu_name(),
|
|
620
|
-
MEM=get_mem_total(),
|
|
627
|
+
template = fetch_header(
|
|
628
|
+
file.removeprefix("benchmark_result_").removesuffix(".json")
|
|
621
629
|
)
|
|
622
630
|
|
|
623
631
|
for index_s in INDEXES:
|
ssrjson_benchmark/template.md
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssrjson-benchmark
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: benchmark of ssrJSON
|
|
5
5
|
Author-email: Eritque Arcus <eritque-arcus@ikuyo.dev>, Antares <antares0982@gmail.com>
|
|
6
|
-
License
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Eritque arcus
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
7
28
|
Project-URL: Homepage, https://github.com/Nambers/ssrJSON-benchmark
|
|
8
29
|
Project-URL: Issues, https://github.com/Nambers/ssrJSON-benchmark/issues
|
|
9
30
|
Project-URL: Repository, https://github.com/Nambers/ssrJSON-benchmark.git
|
|
@@ -19,6 +40,7 @@ Description-Content-Type: text/markdown
|
|
|
19
40
|
License-File: LICENSE
|
|
20
41
|
Requires-Dist: ssrjson
|
|
21
42
|
Requires-Dist: orjson
|
|
43
|
+
Requires-Dist: ujson
|
|
22
44
|
Requires-Dist: matplotlib
|
|
23
45
|
Provides-Extra: pdf
|
|
24
46
|
Requires-Dist: svglib; extra == "pdf"
|
|
@@ -63,7 +85,7 @@ python -m ssrjson_benchmark
|
|
|
63
85
|
|
|
64
86
|
## Notes
|
|
65
87
|
|
|
66
|
-
* This repository conducts benchmarking using json, orjson, and ssrJSON. The `dumps` benchmark produces str objects, comparing three operations: `json.dumps`, `orjson.dumps` followed by decode, and `ssrjson.dumps`. The `dumps_to_bytes` benchmark produces bytes objects, comparing three functions: `json.dumps` followed by encode, `orjson.dumps`, and `ssrjson.dumps_to_bytes`.
|
|
88
|
+
* This repository conducts benchmarking using json, [orjson](https://github.com/ijl/orjson), [ujson](https://github.com/ultrajson/ultrajson), and [ssrJSON](https://github.com/Antares0982/ssrjson). The `dumps` benchmark produces str objects, comparing three operations: `json.dumps`, `orjson.dumps` followed by decode, and `ssrjson.dumps`. The `dumps_to_bytes` benchmark produces bytes objects, comparing three functions: `json.dumps` followed by encode, `orjson.dumps`, and `ssrjson.dumps_to_bytes`.
|
|
67
89
|
* When orjson handles non-ASCII strings, if the cache of the `PyUnicodeObject`’s UTF-8 representation does not exist, it invokes the `PyUnicode_AsUTF8AndSize` function to obtain the UTF-8 encoding. This function then caches the UTF-8 representation within the `PyUnicodeObject`. If the same `PyUnicodeObject` undergoes repeated encode-decode operations, subsequent calls after the initial one will execute more quickly due to this caching. However, in real-world production scenarios, it is uncommon to perform JSON encode-decode repeatedly on the exact same string object; even identical strings are unlikely to be the same object instance. To achieve benchmark results that better reflect practical use cases, we employ `ssrjson.run_unicode_accumulate_benchmark` and `benchmark_invalidate_dump_cache` functions, which ensure that new `PyUnicodeObject`s are different for each input every time. (ref: [orjson#586](https://github.com/ijl/orjson/issues/586))
|
|
68
90
|
* The performance of JSON encoding is primarily constrained by the speed of writing to the buffer, whereas decoding performance is mainly limited by the frequent invocation of CPython interfaces for object creation. During decoding, both ssrJSON and orjson employ short key caching to reduce the number of object creations, and this caching mechanism is global in both cases. As a result, decoding benchmark tests may not accurately reflect the conditions encountered in real-world production environments.
|
|
69
91
|
* The files simple_object.json and simple_object_zh.json do not represent real-world data; they are solely used to compare the performance of the fast path. Therefore, the benchmark results should not be interpreted as indicative of actual performance.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ssrjson_benchmark/__init__.py,sha256=aroqyK7Q7TXRsbBm92uxbpKePybt3edk08_00dfIgas,368
|
|
2
2
|
ssrjson_benchmark/__main__.py,sha256=3Nn6E4C6zFDArGDmiB36YOq4pX51KbJc3nKjcjBxRRs,1281
|
|
3
|
-
ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=
|
|
4
|
-
ssrjson_benchmark/benchmark_main.py,sha256=
|
|
5
|
-
ssrjson_benchmark/template.md,sha256=
|
|
3
|
+
ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=zOxjGx2i03BWn4Qe-6BV2e8Duc65mDoNsNF11jPa2AQ,13312
|
|
4
|
+
ssrjson_benchmark/benchmark_main.py,sha256=wORO_z7a45gde25GeEfR2_rZ_Jdto4e16gvq3_tKUbE,21520
|
|
5
|
+
ssrjson_benchmark/template.md,sha256=ZRM36XR-EB2Up0BkRiE1IL7GmlaozwNQ-S1TFw_hnwM,272
|
|
6
6
|
ssrjson_benchmark/_files/MotionsQuestionsAnswersQuestions2016.json,sha256=EqcdpROZfEPUSuOq1PXmDY3WXQqPvNYmvqAYF_30ICQ,10323246
|
|
7
7
|
ssrjson_benchmark/_files/apache.json,sha256=KcnevFmcwUnq5rws-lXkX-Wzqwl_18v3DN9DXp4flLY,129902
|
|
8
8
|
ssrjson_benchmark/_files/canada.json,sha256=RA04pPSDmkpferPrNeauJGUYzbB1VgmXFP2gA6ZXKYE,3546333
|
|
@@ -15,8 +15,8 @@ ssrjson_benchmark/_files/simple_object_zh.json,sha256=uPOPBRqqFwxxu1Sh0DMoe1q9o3
|
|
|
15
15
|
ssrjson_benchmark/_files/truenull.json,sha256=enl_cy6qWa8b7bdVpx3-e0k6X9BFe_aCPot1rEquGiU,12000
|
|
16
16
|
ssrjson_benchmark/_files/tweet.json,sha256=nd_aAjLwHMcvzh_4ntacdK6S1Dlz65bcsPEzS-9MEtc,5128
|
|
17
17
|
ssrjson_benchmark/_files/twitter.json,sha256=apbJI9QLVdnFuler9fbDV8AyK9Tz2AuygSujmeMKn2o,770627
|
|
18
|
-
ssrjson_benchmark-0.0.
|
|
19
|
-
ssrjson_benchmark-0.0.
|
|
20
|
-
ssrjson_benchmark-0.0.
|
|
21
|
-
ssrjson_benchmark-0.0.
|
|
22
|
-
ssrjson_benchmark-0.0.
|
|
18
|
+
ssrjson_benchmark-0.0.3.dist-info/licenses/LICENSE,sha256=grt4_GrNwicUFuNLSSbvvdGq2fFW6s81CFBO9_mtQbg,1091
|
|
19
|
+
ssrjson_benchmark-0.0.3.dist-info/METADATA,sha256=iKoZ-6wjL7f6GnMzcH7IYHtAuxsfgR86KLYIvK7BDzc,5884
|
|
20
|
+
ssrjson_benchmark-0.0.3.dist-info/WHEEL,sha256=XkFE14KmFh7mutkkb-qn_ueuH2lwfT8rLdfc5xpQ7wE,99
|
|
21
|
+
ssrjson_benchmark-0.0.3.dist-info/top_level.txt,sha256=l1O9IjI1lR5DczhKv9O-GeItgq5HZySDOI5KjfFfvq8,37
|
|
22
|
+
ssrjson_benchmark-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|