MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/benchmark/json/main.cpp:167–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167int main(int argc, char* argv[]) {
168 char ch;
169 int max = 100;
170 acl::string filename = "./test.json";
171
172 while ((ch = getopt(argc, argv, "hf:n:")) > 0) {
173 switch (ch) {
174 case 'h':
175 usage(argv[0]);
176 return 0;
177 case 'f':
178 filename = optarg;
179 break;
180 case 'n':
181 max = atoi(optarg);
182 break;
183 default:
184 break;
185 }
186 }
187
188 acl::string data;
189 if (!acl::ifstream::load(filename, data)) {
190 printf("load data from %s error %s\r\n",
191 filename.c_str(), acl::last_serror());
192 return 1;
193 }
194
195 size_t dlen = data.size();
196
197 struct timeval begin;
198 struct timeval end;
199 int count;
200 double cost, speed, size;
201
202#ifdef HAS_YYJSON
203 gettimeofday(&begin, NULL);
204
205 count = yyjson_test(data, max);
206
207 gettimeofday(&end, NULL);
208 cost = acl::stamp_sub(end, begin);
209 speed = (count * 1000) / (cost > 0 ? cost : 0.1);
210 size = (dlen * speed) / (1024 * 1024);
211
212 printf("yyjson: count=%d, cost=%.2f ms, speed=%.2f, size=%.2f MB\r\n",
213 max, cost, speed, size);
214#endif
215
216 /////////////////////////////////////////////////////////////////////
217
218#ifdef HAS_SIMDJSON
219 gettimeofday(&begin, NULL);
220 count = simdjson_test(data, max);
221 gettimeofday(&end, NULL);
222
223 cost = acl::stamp_sub(end, begin);
224 speed = (count * 1000) / (cost > 0 ? cost : 0.1);

Callers

nothing calls this directly

Calls 14

yyjson_testFunction · 0.85
simdjson_testFunction · 0.85
cjson_testFunction · 0.85
rapidjson_testFunction · 0.85
jtjson_testFunction · 0.85
acl_cppjson_testFunction · 0.85
acl_cjson_testFunction · 0.85
usageFunction · 0.70
getoptFunction · 0.50
last_serrorFunction · 0.50
gettimeofdayFunction · 0.50
stamp_subFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…