|
10 | 10 |
|
11 | 11 | from .util import read_fixture_obj, read_fixture_str |
12 | 12 |
|
| 13 | + |
13 | 14 | def orjson_dumps(obj): |
14 | 15 | return _orjson_dumps(obj) |
15 | 16 |
|
| 17 | + |
16 | 18 | def ujson_dumps(obj): |
17 | | - return _ujson_dumps(obj).encode('utf-8') |
| 19 | + return _ujson_dumps(obj).encode("utf-8") |
| 20 | + |
18 | 21 |
|
19 | 22 | def rapidjson_dumps(obj): |
20 | | - return _rapidjson_dumps(obj).encode('utf-8') |
| 23 | + return _rapidjson_dumps(obj).encode("utf-8") |
| 24 | + |
21 | 25 |
|
22 | 26 | def json_dumps(obj): |
23 | | - return _json_dumps(obj).encode('utf-8') |
| 27 | + return _json_dumps(obj).encode("utf-8") |
| 28 | + |
24 | 29 |
|
25 | 30 | def simplejson_dumps(obj): |
26 | | - return _simplejson_dumps(obj).encode('utf-8') |
| 31 | + return _simplejson_dumps(obj).encode("utf-8") |
| 32 | + |
27 | 33 |
|
28 | 34 | def test_dumps_canada_orjson(benchmark): |
29 | | - benchmark.group = 'canada.json serialization' |
30 | | - benchmark.extra_info['lib'] = 'orjson' |
| 35 | + benchmark.group = "canada.json serialization" |
| 36 | + benchmark.extra_info["lib"] = "orjson" |
31 | 37 | data = read_fixture_obj("canada.json.xz") |
32 | | - benchmark.extra_info['correct'] = json_loads(orjson_dumps(data)) == data |
| 38 | + benchmark.extra_info["correct"] = json_loads(orjson_dumps(data)) == data |
33 | 39 | benchmark(orjson_dumps, data) |
34 | 40 |
|
| 41 | + |
35 | 42 | def test_dumps_canada_ujson(benchmark): |
36 | | - benchmark.group = 'canada.json serialization' |
37 | | - benchmark.extra_info['lib'] = 'ujson' |
| 43 | + benchmark.group = "canada.json serialization" |
| 44 | + benchmark.extra_info["lib"] = "ujson" |
38 | 45 | data = read_fixture_obj("canada.json.xz") |
39 | | - benchmark.extra_info['correct'] = json_loads(ujson_dumps(data)) == data |
| 46 | + benchmark.extra_info["correct"] = json_loads(ujson_dumps(data)) == data |
40 | 47 | benchmark(ujson_dumps, data) |
41 | 48 |
|
| 49 | + |
42 | 50 | def test_dumps_canada_json(benchmark): |
43 | | - benchmark.group = 'canada.json serialization' |
44 | | - benchmark.extra_info['lib'] = 'json' |
| 51 | + benchmark.group = "canada.json serialization" |
| 52 | + benchmark.extra_info["lib"] = "json" |
45 | 53 | data = read_fixture_obj("canada.json.xz") |
46 | | - benchmark.extra_info['correct'] = json_loads(json_dumps(data)) == data |
| 54 | + benchmark.extra_info["correct"] = json_loads(json_dumps(data)) == data |
47 | 55 | benchmark(json_dumps, data) |
48 | 56 |
|
| 57 | + |
49 | 58 | def test_dumps_canada_rapidjson(benchmark): |
50 | | - benchmark.group = 'canada.json serialization' |
51 | | - benchmark.extra_info['lib'] = 'rapidjson' |
| 59 | + benchmark.group = "canada.json serialization" |
| 60 | + benchmark.extra_info["lib"] = "rapidjson" |
52 | 61 | data = read_fixture_obj("canada.json.xz") |
53 | | - benchmark.extra_info['correct'] = json_loads(rapidjson_dumps(data)) == data |
| 62 | + benchmark.extra_info["correct"] = json_loads(rapidjson_dumps(data)) == data |
54 | 63 | benchmark(rapidjson_dumps, data) |
55 | 64 |
|
| 65 | + |
56 | 66 | def test_dumps_canada_simplejson(benchmark): |
57 | | - benchmark.group = 'canada.json serialization' |
58 | | - benchmark.extra_info['lib'] = 'simplejson' |
| 67 | + benchmark.group = "canada.json serialization" |
| 68 | + benchmark.extra_info["lib"] = "simplejson" |
59 | 69 | data = read_fixture_obj("canada.json.xz") |
60 | | - benchmark.extra_info['correct'] = json_loads(simplejson_dumps(data)) == data |
| 70 | + benchmark.extra_info["correct"] = json_loads(simplejson_dumps(data)) == data |
61 | 71 | benchmark(simplejson_dumps, data) |
62 | 72 |
|
| 73 | + |
63 | 74 | def test_dumps_citm_catalog_orjson(benchmark): |
64 | | - benchmark.group = 'citm_catalog.json serialization' |
65 | | - benchmark.extra_info['lib'] = 'orjson' |
| 75 | + benchmark.group = "citm_catalog.json serialization" |
| 76 | + benchmark.extra_info["lib"] = "orjson" |
66 | 77 | data = read_fixture_obj("citm_catalog.json.xz") |
67 | | - benchmark.extra_info['correct'] = json_loads(orjson_dumps(data)) == data |
| 78 | + benchmark.extra_info["correct"] = json_loads(orjson_dumps(data)) == data |
68 | 79 | benchmark(orjson_dumps, data) |
69 | 80 |
|
| 81 | + |
70 | 82 | def test_dumps_citm_catalog_ujson(benchmark): |
71 | | - benchmark.group = 'citm_catalog.json serialization' |
72 | | - benchmark.extra_info['lib'] = 'ujson' |
| 83 | + benchmark.group = "citm_catalog.json serialization" |
| 84 | + benchmark.extra_info["lib"] = "ujson" |
73 | 85 | data = read_fixture_obj("citm_catalog.json.xz") |
74 | | - benchmark.extra_info['correct'] = json_loads(ujson_dumps(data)) == data |
| 86 | + benchmark.extra_info["correct"] = json_loads(ujson_dumps(data)) == data |
75 | 87 | benchmark(ujson_dumps, data) |
76 | 88 |
|
| 89 | + |
77 | 90 | def test_dumps_citm_catalog_json(benchmark): |
78 | | - benchmark.group = 'citm_catalog.json serialization' |
79 | | - benchmark.extra_info['lib'] = 'json' |
| 91 | + benchmark.group = "citm_catalog.json serialization" |
| 92 | + benchmark.extra_info["lib"] = "json" |
80 | 93 | data = read_fixture_obj("citm_catalog.json.xz") |
81 | | - benchmark.extra_info['correct'] = json_loads(json_dumps(data)) == data |
| 94 | + benchmark.extra_info["correct"] = json_loads(json_dumps(data)) == data |
82 | 95 | benchmark(json_dumps, data) |
83 | 96 |
|
| 97 | + |
84 | 98 | def test_dumps_citm_catalog_rapidjson(benchmark): |
85 | | - benchmark.group = 'citm_catalog.json serialization' |
86 | | - benchmark.extra_info['lib'] = 'rapidjson' |
| 99 | + benchmark.group = "citm_catalog.json serialization" |
| 100 | + benchmark.extra_info["lib"] = "rapidjson" |
87 | 101 | data = read_fixture_obj("citm_catalog.json.xz") |
88 | | - benchmark.extra_info['correct'] = json_loads(rapidjson_dumps(data)) == data |
| 102 | + benchmark.extra_info["correct"] = json_loads(rapidjson_dumps(data)) == data |
89 | 103 | benchmark(rapidjson_dumps, data) |
90 | 104 |
|
| 105 | + |
91 | 106 | def test_dumps_citm_catalog_simplejson(benchmark): |
92 | | - benchmark.group = 'citm_catalog.json serialization' |
93 | | - benchmark.extra_info['lib'] = 'simplejson' |
| 107 | + benchmark.group = "citm_catalog.json serialization" |
| 108 | + benchmark.extra_info["lib"] = "simplejson" |
94 | 109 | data = read_fixture_obj("citm_catalog.json.xz") |
95 | | - benchmark.extra_info['correct'] = json_loads(simplejson_dumps(data)) == data |
| 110 | + benchmark.extra_info["correct"] = json_loads(simplejson_dumps(data)) == data |
96 | 111 | benchmark(simplejson_dumps, data) |
97 | 112 |
|
| 113 | + |
98 | 114 | def test_dumps_github_orjson(benchmark): |
99 | | - benchmark.group = 'github.json serialization' |
100 | | - benchmark.extra_info['lib'] = 'orjson' |
| 115 | + benchmark.group = "github.json serialization" |
| 116 | + benchmark.extra_info["lib"] = "orjson" |
101 | 117 | data = read_fixture_obj("github.json.xz") |
102 | | - benchmark.extra_info['correct'] = json_loads(orjson_dumps(data)) == data |
| 118 | + benchmark.extra_info["correct"] = json_loads(orjson_dumps(data)) == data |
103 | 119 | benchmark(orjson_dumps, data) |
104 | 120 |
|
| 121 | + |
105 | 122 | def test_dumps_github_ujson(benchmark): |
106 | | - benchmark.group = 'github.json serialization' |
107 | | - benchmark.extra_info['lib'] = 'ujson' |
| 123 | + benchmark.group = "github.json serialization" |
| 124 | + benchmark.extra_info["lib"] = "ujson" |
108 | 125 | data = read_fixture_obj("github.json.xz") |
109 | | - benchmark.extra_info['correct'] = json_loads(ujson_dumps(data)) == data |
| 126 | + benchmark.extra_info["correct"] = json_loads(ujson_dumps(data)) == data |
110 | 127 | benchmark(ujson_dumps, data) |
111 | 128 |
|
| 129 | + |
112 | 130 | def test_dumps_github_json(benchmark): |
113 | | - benchmark.group = 'github.json serialization' |
114 | | - benchmark.extra_info['lib'] = 'json' |
| 131 | + benchmark.group = "github.json serialization" |
| 132 | + benchmark.extra_info["lib"] = "json" |
115 | 133 | data = read_fixture_obj("github.json.xz") |
116 | | - benchmark.extra_info['correct'] = json_loads(json_dumps(data)) == data |
| 134 | + benchmark.extra_info["correct"] = json_loads(json_dumps(data)) == data |
117 | 135 | benchmark(json_dumps, data) |
118 | 136 |
|
| 137 | + |
119 | 138 | def test_dumps_github_rapidjson(benchmark): |
120 | | - benchmark.group = 'github.json serialization' |
121 | | - benchmark.extra_info['lib'] = 'rapidjson' |
| 139 | + benchmark.group = "github.json serialization" |
| 140 | + benchmark.extra_info["lib"] = "rapidjson" |
122 | 141 | data = read_fixture_obj("github.json.xz") |
123 | | - benchmark.extra_info['correct'] = json_loads(rapidjson_dumps(data)) == data |
| 142 | + benchmark.extra_info["correct"] = json_loads(rapidjson_dumps(data)) == data |
124 | 143 | benchmark(rapidjson_dumps, data) |
125 | 144 |
|
| 145 | + |
126 | 146 | def test_dumps_github_simplejson(benchmark): |
127 | | - benchmark.group = 'github.json serialization' |
128 | | - benchmark.extra_info['lib'] = 'simplejson' |
| 147 | + benchmark.group = "github.json serialization" |
| 148 | + benchmark.extra_info["lib"] = "simplejson" |
129 | 149 | data = read_fixture_obj("github.json.xz") |
130 | | - benchmark.extra_info['correct'] = json_loads(simplejson_dumps(data)) == data |
| 150 | + benchmark.extra_info["correct"] = json_loads(simplejson_dumps(data)) == data |
131 | 151 | benchmark(simplejson_dumps, data) |
132 | 152 |
|
| 153 | + |
133 | 154 | def test_dumps_twitter_orjson(benchmark): |
134 | | - benchmark.group = 'twitter.json serialization' |
135 | | - benchmark.extra_info['lib'] = 'orjson' |
| 155 | + benchmark.group = "twitter.json serialization" |
| 156 | + benchmark.extra_info["lib"] = "orjson" |
136 | 157 | data = read_fixture_obj("twitter.json.xz") |
137 | | - benchmark.extra_info['correct'] = json_loads(orjson_dumps(data)) == data |
| 158 | + benchmark.extra_info["correct"] = json_loads(orjson_dumps(data)) == data |
138 | 159 | benchmark(orjson_dumps, data) |
139 | 160 |
|
| 161 | + |
140 | 162 | def test_dumps_twitter_ujson(benchmark): |
141 | | - benchmark.group = 'twitter.json serialization' |
142 | | - benchmark.extra_info['lib'] = 'ujson' |
| 163 | + benchmark.group = "twitter.json serialization" |
| 164 | + benchmark.extra_info["lib"] = "ujson" |
143 | 165 | data = read_fixture_obj("twitter.json.xz") |
144 | | - benchmark.extra_info['correct'] = json_loads(ujson_dumps(data)) == data |
| 166 | + benchmark.extra_info["correct"] = json_loads(ujson_dumps(data)) == data |
145 | 167 | benchmark(ujson_dumps, data) |
146 | 168 |
|
| 169 | + |
147 | 170 | def test_dumps_twitter_json(benchmark): |
148 | | - benchmark.group = 'twitter.json serialization' |
149 | | - benchmark.extra_info['lib'] = 'json' |
| 171 | + benchmark.group = "twitter.json serialization" |
| 172 | + benchmark.extra_info["lib"] = "json" |
150 | 173 | data = read_fixture_obj("twitter.json.xz") |
151 | | - benchmark.extra_info['correct'] = json_loads(json_dumps(data)) == data |
| 174 | + benchmark.extra_info["correct"] = json_loads(json_dumps(data)) == data |
152 | 175 | benchmark(json_dumps, data) |
153 | 176 |
|
| 177 | + |
154 | 178 | def test_dumps_twitter_rapidjson(benchmark): |
155 | | - benchmark.group = 'twitter.json serialization' |
156 | | - benchmark.extra_info['lib'] = 'rapidjson' |
| 179 | + benchmark.group = "twitter.json serialization" |
| 180 | + benchmark.extra_info["lib"] = "rapidjson" |
157 | 181 | data = read_fixture_obj("twitter.json.xz") |
158 | | - benchmark.extra_info['correct'] = json_loads(rapidjson_dumps(data)) == data |
| 182 | + benchmark.extra_info["correct"] = json_loads(rapidjson_dumps(data)) == data |
159 | 183 | benchmark(rapidjson_dumps, data) |
160 | 184 |
|
| 185 | + |
161 | 186 | def test_dumps_twitter_simplejson(benchmark): |
162 | | - benchmark.group = 'twitter.json serialization' |
163 | | - benchmark.extra_info['lib'] = 'simplejson' |
| 187 | + benchmark.group = "twitter.json serialization" |
| 188 | + benchmark.extra_info["lib"] = "simplejson" |
164 | 189 | data = read_fixture_obj("twitter.json.xz") |
165 | | - benchmark.extra_info['correct'] = json_loads(simplejson_dumps(data)) == data |
| 190 | + benchmark.extra_info["correct"] = json_loads(simplejson_dumps(data)) == data |
166 | 191 | benchmark(simplejson_dumps, data) |
0 commit comments