| 165 | } |
| 166 | |
| 167 | int 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); |
nothing calls this directly
no test coverage detected
searching dependent graphs…