ssrjson-benchmark 0.0.3__cp310-cp310-win_amd64.whl → 0.0.4__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.

@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ssrjson-benchmark
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: benchmark of ssrJSON
5
5
  Author-email: Eritque Arcus <eritque-arcus@ikuyo.dev>, Antares <antares0982@gmail.com>
6
6
  License: MIT License
@@ -86,6 +86,6 @@ python -m ssrjson_benchmark
86
86
  ## Notes
87
87
 
88
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`.
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))
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))
90
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.
91
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,7 +1,8 @@
1
- ssrjson_benchmark/__init__.py,sha256=aroqyK7Q7TXRsbBm92uxbpKePybt3edk08_00dfIgas,368
2
- ssrjson_benchmark/__main__.py,sha256=3Nn6E4C6zFDArGDmiB36YOq4pX51KbJc3nKjcjBxRRs,1281
3
- ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=QTtSvRkCUMqfLyWq4FHfRJfazg8YWUtD6RjRLeEDzNA,13312
4
- ssrjson_benchmark/benchmark_main.py,sha256=wORO_z7a45gde25GeEfR2_rZ_Jdto4e16gvq3_tKUbE,21520
1
+ ssrjson_benchmark/__init__.py,sha256=i4lVJ3CRKTxfxGyXREUi5OUesvmwWm8fEkcME7usGpk,380
2
+ ssrjson_benchmark/__main__.py,sha256=PQgkJRKuQT9NPQ3JZD7qyAbHhRKbh9UvkxOlXsJnITA,2312
3
+ ssrjson_benchmark/_ssrjson_benchmark.pyd,sha256=Z15oFGhdAWs8RKyYngxiAFRcvUQvtbUZ-1FYsTHcQw0,13312
4
+ ssrjson_benchmark/benchmark_impl.py,sha256=5yRsbhcB5jz1VC4wuNgI4BZndZVxogW3_obz9jC2OBA,23828
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.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=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
21
- ssrjson_benchmark-0.0.3.dist-info/top_level.txt,sha256=l1O9IjI1lR5DczhKv9O-GeItgq5HZySDOI5KjfFfvq8,37
22
- ssrjson_benchmark-0.0.3.dist-info/RECORD,,
19
+ ssrjson_benchmark-0.0.4.dist-info/licenses/LICENSE,sha256=grt4_GrNwicUFuNLSSbvvdGq2fFW6s81CFBO9_mtQbg,1091
20
+ ssrjson_benchmark-0.0.4.dist-info/METADATA,sha256=9LlYrNP1-cBf3hP8WakHkcFLNVBNzwVNCT8JqFAji08,5885
21
+ ssrjson_benchmark-0.0.4.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
22
+ ssrjson_benchmark-0.0.4.dist-info/top_level.txt,sha256=l1O9IjI1lR5DczhKv9O-GeItgq5HZySDOI5KjfFfvq8,37
23
+ ssrjson_benchmark-0.0.4.dist-info/RECORD,,