ssrjson-benchmark 0.0.5__cp314-cp314-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.

@@ -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)
@@ -0,0 +1,11 @@
1
+ # ssrJSON benchmark Report
2
+
3
+ REV: `{REV}`
4
+ Python: `{PYTHON}`
5
+ Orjson: `{ORJSON_VER}`
6
+ Ujson: `{UJSON_VER}`
7
+ Generated time: {TIME}
8
+ OS: {OS}
9
+ SIMD flag: {SIMD_FLAGS}
10
+ Chipset: {CHIPSET}
11
+ Memory: {MEM}
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: ssrjson-benchmark
3
+ Version: 0.0.5
4
+ Summary: benchmark of ssrJSON
5
+ Author-email: Eritque Arcus <eritque-arcus@ikuyo.dev>, Antares <antares0982@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nambers/ssrJSON-benchmark
8
+ Project-URL: Issues, https://github.com/Nambers/ssrJSON-benchmark/issues
9
+ Project-URL: Repository, https://github.com/Nambers/ssrJSON-benchmark.git
10
+ Keywords: ssrjson,benchmark,json
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: System :: Benchmark
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: ssrjson
21
+ Requires-Dist: orjson
22
+ Requires-Dist: ujson
23
+ Requires-Dist: matplotlib
24
+ Provides-Extra: pdf
25
+ Requires-Dist: svglib; extra == "pdf"
26
+ Requires-Dist: reportlab; extra == "pdf"
27
+ Provides-Extra: cpuinfo
28
+ Requires-Dist: py-cpuinfo; extra == "cpuinfo"
29
+ Dynamic: license-file
30
+
31
+ # ssrJSON-benchmark
32
+
33
+ <div align="center">
34
+
35
+ [![PyPI - Version](https://img.shields.io/pypi/v/ssrjson-benchmark)](https://pypi.org/project/ssrjson-benchmark/) [![PyPI - Wheel](https://img.shields.io/pypi/wheel/ssrjson-benchmark)](https://pypi.org/project/ssrjson-benchmark/)
36
+
37
+ The [ssrJSON](https://github.com/Antares0982/ssrjson) benchmark repository.
38
+
39
+ </div>
40
+
41
+ ## Benchmark Results
42
+
43
+ The benchmark results can be found in [website results](https://ikuyo.dev/ssrJSON-benchmark/) or [GitHub results](https://github.com/Nambers/ssrJSON-benchmark/tree/main/results). Contributing your benchmark result is welcomed.
44
+
45
+ Quick jump for
46
+
47
+ * [x86-64-v2, SSE4.2](https://github.com/Nambers/ssrJSON-benchmark/tree/main/results/SSE4.2)
48
+ * [x86-64-v3, AVX2](https://github.com/Nambers/ssrJSON-benchmark/tree/main/results/AVX2)
49
+ * [x86-64-v4, AVX512](https://github.com/Nambers/ssrJSON-benchmark/tree/main/results/AVX512)
50
+
51
+ ## Usage
52
+
53
+ ```bash
54
+ # you may need to install `svglib`, `reportlab` and `py-cpuinfo` as well
55
+ pip install ssrjson-benchmark
56
+ python -m ssrjson_benchmark
57
+ ```
58
+
59
+ ## Benchmark options
60
+
61
+ * `-m` output in Markdown instead of PDF.
62
+ * `-f <json_path>` used exists benchmark json result.
63
+ * `--process-bytes <bytes_num>` Total process bytes per test, default 1e8.
64
+
65
+ ## Notes
66
+
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`.
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))
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.
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.
@@ -0,0 +1,23 @@
1
+ ssrjson_benchmark/__init__.py,sha256=i4lVJ3CRKTxfxGyXREUi5OUesvmwWm8fEkcME7usGpk,380
2
+ ssrjson_benchmark/__main__.py,sha256=kCW5S5avgZcb2W4I4Mlb0ytXCF9epg4P441JEJywxac,2901
3
+ ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=73AsKZQDRiVI755fi3pNDxAzU_MiUMcKmvYmK4lW63U,13312
4
+ ssrjson_benchmark/benchmark_impl.py,sha256=rsrRX5FP6XFvcXybrL9rAjDLlgAkzSRpvOlivRJAs_4,25953
5
+ ssrjson_benchmark/result_types.py,sha256=_rrM4Lz4-8fJhtHQ9tOF2tr6dRc-FU4CmabodUO_hk8,2379
6
+ ssrjson_benchmark/template.md,sha256=ZRM36XR-EB2Up0BkRiE1IL7GmlaozwNQ-S1TFw_hnwM,272
7
+ ssrjson_benchmark/_files/MotionsQuestionsAnswersQuestions2016.json,sha256=EqcdpROZfEPUSuOq1PXmDY3WXQqPvNYmvqAYF_30ICQ,10323246
8
+ ssrjson_benchmark/_files/apache.json,sha256=KcnevFmcwUnq5rws-lXkX-Wzqwl_18v3DN9DXp4flLY,129902
9
+ ssrjson_benchmark/_files/canada.json,sha256=RA04pPSDmkpferPrNeauJGUYzbB1VgmXFP2gA6ZXKYE,3546333
10
+ ssrjson_benchmark/_files/ctm.json,sha256=8eKMAlsR0aRx8HkBfZpvBx5T_wTA1btXfQ4TPCuuEis,1740628
11
+ ssrjson_benchmark/_files/github.json,sha256=qPmii-EnL8xRe9Wd5hbCOA0b6HpC3JIGjUmPTimnwKM,69150
12
+ ssrjson_benchmark/_files/instruments.json,sha256=V4WOeHEw873w-35OoUFFx9lM1KKnCWK_h-22O8UoHPU,201267
13
+ ssrjson_benchmark/_files/mesh.json,sha256=uwL2QbjpzBPY-lWLO-Fsk2p3MqSngFkCEItlh3h68tE,756008
14
+ ssrjson_benchmark/_files/simple_object.json,sha256=QTk10imVHGAO95cxEWMxCsZliEfejxVewemhZxjhjSw,36912
15
+ ssrjson_benchmark/_files/simple_object_zh.json,sha256=uPOPBRqqFwxxu1Sh0DMoe1q9o3HeiOJTXUSUSFOGKDo,110496
16
+ ssrjson_benchmark/_files/truenull.json,sha256=enl_cy6qWa8b7bdVpx3-e0k6X9BFe_aCPot1rEquGiU,12000
17
+ ssrjson_benchmark/_files/tweet.json,sha256=nd_aAjLwHMcvzh_4ntacdK6S1Dlz65bcsPEzS-9MEtc,5128
18
+ ssrjson_benchmark/_files/twitter.json,sha256=apbJI9QLVdnFuler9fbDV8AyK9Tz2AuygSujmeMKn2o,770627
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=7k6Wcy588iJYe5lf5K095NLg-uoBTnE-T8eHJ92G4_4,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,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Eritque arcus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ _ssrjson_benchmark
2
+ ssrjson_benchmark