ssrjson-benchmark 0.0.3__cp310-cp310-win_amd64.whl → 0.0.5__cp310-cp310-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/__init__.py +10 -8
- ssrjson_benchmark/__main__.py +62 -19
- ssrjson_benchmark/_ssrjson_benchmark.pyd +0 -0
- ssrjson_benchmark/benchmark_impl.py +826 -0
- ssrjson_benchmark/result_types.py +88 -0
- {ssrjson_benchmark-0.0.3.dist-info → ssrjson_benchmark-0.0.5.dist-info}/METADATA +4 -25
- {ssrjson_benchmark-0.0.3.dist-info → ssrjson_benchmark-0.0.5.dist-info}/RECORD +10 -9
- ssrjson_benchmark/benchmark_main.py +0 -676
- {ssrjson_benchmark-0.0.3.dist-info → ssrjson_benchmark-0.0.5.dist-info}/WHEEL +0 -0
- {ssrjson_benchmark-0.0.3.dist-info → ssrjson_benchmark-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {ssrjson_benchmark-0.0.3.dist-info → ssrjson_benchmark-0.0.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import TYPE_CHECKING, Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BenchmarkResultBase(dict):
|
|
6
|
+
ATTRS = ()
|
|
7
|
+
DEFAULT_SECTION_CLS = dict
|
|
8
|
+
|
|
9
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
10
|
+
self[name] = value
|
|
11
|
+
|
|
12
|
+
def __getitem__(self, key: Any) -> Any:
|
|
13
|
+
try:
|
|
14
|
+
return super().__getitem__(key)
|
|
15
|
+
except KeyError:
|
|
16
|
+
cls = getattr(self.__class__, "DEFAULT_SECTION_CLS", None)
|
|
17
|
+
if cls is None:
|
|
18
|
+
raise
|
|
19
|
+
obj = cls()
|
|
20
|
+
super().__setitem__(key, obj)
|
|
21
|
+
return obj
|
|
22
|
+
|
|
23
|
+
def __getattr__(self, attrname):
|
|
24
|
+
try:
|
|
25
|
+
return self.__getitem__(attrname)
|
|
26
|
+
except KeyError:
|
|
27
|
+
raise AttributeError(attrname)
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def parse(cls, j):
|
|
31
|
+
self = cls()
|
|
32
|
+
for k, v in j.items():
|
|
33
|
+
if k in cls.ATTRS:
|
|
34
|
+
setattr(self, k, v)
|
|
35
|
+
else:
|
|
36
|
+
setattr(self, k, cls.DEFAULT_SECTION_CLS.parse(v))
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class BenchmarkResultPerFileTargetLib(BenchmarkResultBase):
|
|
41
|
+
speed: int
|
|
42
|
+
ratio: float
|
|
43
|
+
ATTRS = ("speed", "ratio")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class BenchmarkResultPerFileTarget(BenchmarkResultBase):
|
|
47
|
+
DEFAULT_SECTION_CLS = BenchmarkResultPerFileTargetLib
|
|
48
|
+
ATTRS = ("ssrjson_bytes_per_sec",)
|
|
49
|
+
ssrjson_bytes_per_sec: float
|
|
50
|
+
|
|
51
|
+
if TYPE_CHECKING:
|
|
52
|
+
|
|
53
|
+
def __getitem__(self, key: str) -> BenchmarkResultPerFileTargetLib: ...
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class BenchmarkResultPerFile(BenchmarkResultBase):
|
|
57
|
+
DEFAULT_SECTION_CLS = BenchmarkResultPerFileTarget
|
|
58
|
+
ATTRS = (
|
|
59
|
+
"byte_size",
|
|
60
|
+
"pyunicode_size",
|
|
61
|
+
"pyunicode_kind",
|
|
62
|
+
"pyunicode_is_ascii",
|
|
63
|
+
)
|
|
64
|
+
byte_size: int
|
|
65
|
+
pyunicode_size: int
|
|
66
|
+
pyunicode_kind: int
|
|
67
|
+
pyunicode_is_ascii: bool
|
|
68
|
+
|
|
69
|
+
if TYPE_CHECKING:
|
|
70
|
+
|
|
71
|
+
def __getitem__(self, key: str) -> BenchmarkResultPerFileTarget: ...
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class BenchmarkFinalResult(BenchmarkResultBase):
|
|
75
|
+
catagories: list[str]
|
|
76
|
+
results: dict[str, BenchmarkResultPerFile]
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def parse(cls, j):
|
|
80
|
+
ret = cls()
|
|
81
|
+
ret.catagories = j["catagories"]
|
|
82
|
+
ret.results = dict()
|
|
83
|
+
for k, v in j["results"].items():
|
|
84
|
+
ret.results[k] = BenchmarkResultPerFile.parse(v)
|
|
85
|
+
return ret
|
|
86
|
+
|
|
87
|
+
def dumps(self):
|
|
88
|
+
return json.dumps(self, ensure_ascii=False, indent=4)
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssrjson-benchmark
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: benchmark of ssrJSON
|
|
5
5
|
Author-email: Eritque Arcus <eritque-arcus@ikuyo.dev>, Antares <antares0982@gmail.com>
|
|
6
|
-
License: MIT
|
|
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
|
-
|
|
6
|
+
License-Expression: MIT
|
|
28
7
|
Project-URL: Homepage, https://github.com/Nambers/ssrJSON-benchmark
|
|
29
8
|
Project-URL: Issues, https://github.com/Nambers/ssrJSON-benchmark/issues
|
|
30
9
|
Project-URL: Repository, https://github.com/Nambers/ssrJSON-benchmark.git
|
|
@@ -35,7 +14,7 @@ Classifier: Intended Audience :: Developers
|
|
|
35
14
|
Classifier: Topic :: System :: Benchmark
|
|
36
15
|
Classifier: Programming Language :: Python :: 3
|
|
37
16
|
Classifier: Operating System :: OS Independent
|
|
38
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.10
|
|
39
18
|
Description-Content-Type: text/markdown
|
|
40
19
|
License-File: LICENSE
|
|
41
20
|
Requires-Dist: ssrjson
|
|
@@ -86,6 +65,6 @@ python -m ssrjson_benchmark
|
|
|
86
65
|
## Notes
|
|
87
66
|
|
|
88
67
|
* 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`.
|
|
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 `
|
|
68
|
+
* 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))
|
|
90
69
|
* 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.
|
|
91
70
|
* 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,7 +1,8 @@
|
|
|
1
|
-
ssrjson_benchmark/__init__.py,sha256=
|
|
2
|
-
ssrjson_benchmark/__main__.py,sha256=
|
|
3
|
-
ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=
|
|
4
|
-
ssrjson_benchmark/
|
|
1
|
+
ssrjson_benchmark/__init__.py,sha256=i4lVJ3CRKTxfxGyXREUi5OUesvmwWm8fEkcME7usGpk,380
|
|
2
|
+
ssrjson_benchmark/__main__.py,sha256=kCW5S5avgZcb2W4I4Mlb0ytXCF9epg4P441JEJywxac,2901
|
|
3
|
+
ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=_C1QheoqYeX-m70WYK2NgZLWvaxiLxmrS-JiUgjdROk,13312
|
|
4
|
+
ssrjson_benchmark/benchmark_impl.py,sha256=rsrRX5FP6XFvcXybrL9rAjDLlgAkzSRpvOlivRJAs_4,25953
|
|
5
|
+
ssrjson_benchmark/result_types.py,sha256=_rrM4Lz4-8fJhtHQ9tOF2tr6dRc-FU4CmabodUO_hk8,2379
|
|
5
6
|
ssrjson_benchmark/template.md,sha256=ZRM36XR-EB2Up0BkRiE1IL7GmlaozwNQ-S1TFw_hnwM,272
|
|
6
7
|
ssrjson_benchmark/_files/MotionsQuestionsAnswersQuestions2016.json,sha256=EqcdpROZfEPUSuOq1PXmDY3WXQqPvNYmvqAYF_30ICQ,10323246
|
|
7
8
|
ssrjson_benchmark/_files/apache.json,sha256=KcnevFmcwUnq5rws-lXkX-Wzqwl_18v3DN9DXp4flLY,129902
|
|
@@ -15,8 +16,8 @@ ssrjson_benchmark/_files/simple_object_zh.json,sha256=uPOPBRqqFwxxu1Sh0DMoe1q9o3
|
|
|
15
16
|
ssrjson_benchmark/_files/truenull.json,sha256=enl_cy6qWa8b7bdVpx3-e0k6X9BFe_aCPot1rEquGiU,12000
|
|
16
17
|
ssrjson_benchmark/_files/tweet.json,sha256=nd_aAjLwHMcvzh_4ntacdK6S1Dlz65bcsPEzS-9MEtc,5128
|
|
17
18
|
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.
|
|
19
|
+
ssrjson_benchmark-0.0.5.dist-info/licenses/LICENSE,sha256=grt4_GrNwicUFuNLSSbvvdGq2fFW6s81CFBO9_mtQbg,1091
|
|
20
|
+
ssrjson_benchmark-0.0.5.dist-info/METADATA,sha256=c5fakyL6f7a7QLTAl6R9KuPi5JVZac7Xcai-l8f2ET0,4641
|
|
21
|
+
ssrjson_benchmark-0.0.5.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
|
|
22
|
+
ssrjson_benchmark-0.0.5.dist-info/top_level.txt,sha256=l1O9IjI1lR5DczhKv9O-GeItgq5HZySDOI5KjfFfvq8,37
|
|
23
|
+
ssrjson_benchmark-0.0.5.dist-info/RECORD,,
|