ssrjson-benchmark 0.0.2__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.

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 = {"json": "#74c476", "orjson": "#6baed6", "ssrjson": "#fd8d3c"}
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
- "orjson.dumps+decode": lambda x: orjson.dumps(
57
- x, option=orjson.OPT_INDENT_2
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
  },
@@ -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
- with open(os.path.join(CUR_DIR, "template.md"), "r") as f:
580
- template = f.read()
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
- with open(os.path.join(CUR_DIR, "template.md"), "r") as f:
611
- template = f.read()
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:
@@ -3,6 +3,7 @@
3
3
  REV: `{REV}`
4
4
  Python: `{PYTHON}`
5
5
  Orjson: `{ORJSON_VER}`
6
+ Ujson: `{UJSON_VER}`
6
7
  Generated time: {TIME}
7
8
  OS: {OS}
8
9
  SIMD flag: {SIMD_FLAGS}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ssrjson-benchmark
3
- Version: 0.0.2
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
6
  License: MIT License
@@ -40,6 +40,7 @@ Description-Content-Type: text/markdown
40
40
  License-File: LICENSE
41
41
  Requires-Dist: ssrjson
42
42
  Requires-Dist: orjson
43
+ Requires-Dist: ujson
43
44
  Requires-Dist: matplotlib
44
45
  Provides-Extra: pdf
45
46
  Requires-Dist: svglib; extra == "pdf"
@@ -84,7 +85,7 @@ python -m ssrjson_benchmark
84
85
 
85
86
  ## Notes
86
87
 
87
- * 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`.
88
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
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.
90
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=hEQKhEtEPti2lO1dVttWy9xnsLfKwM-_pF0jILRsbaw,13312
4
- ssrjson_benchmark/benchmark_main.py,sha256=hjWIzQPa9gmSw7usSsgZNyVMXkK3B7p0Rkivj1YzwJ0,21507
5
- ssrjson_benchmark/template.md,sha256=P0j37eQs80YQWfwstWu3LbkG5Ek9AEcB83fG7uNuqCI,241
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.2.dist-info/licenses/LICENSE,sha256=grt4_GrNwicUFuNLSSbvvdGq2fFW6s81CFBO9_mtQbg,1091
19
- ssrjson_benchmark-0.0.2.dist-info/METADATA,sha256=RsWHrOFxy9HS69cPJ49CfTUCiipcmYcwmXpXXwRU_60,5738
20
- ssrjson_benchmark-0.0.2.dist-info/WHEEL,sha256=XkFE14KmFh7mutkkb-qn_ueuH2lwfT8rLdfc5xpQ7wE,99
21
- ssrjson_benchmark-0.0.2.dist-info/top_level.txt,sha256=l1O9IjI1lR5DczhKv9O-GeItgq5HZySDOI5KjfFfvq8,37
22
- ssrjson_benchmark-0.0.2.dist-info/RECORD,,
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,,