| 24 | } |
| 25 | |
| 26 | static int header_http(const char* filepath, int max) |
| 27 | { |
| 28 | struct timeval begin, end; |
| 29 | double n; |
| 30 | ACL_VSTREAM* fp; |
| 31 | int i, ret; |
| 32 | |
| 33 | fp = acl_vstream_fopen(filepath, O_RDONLY, 0600, 8192); |
| 34 | if (fp == NULL) |
| 35 | { |
| 36 | printf("open file %s error\r\n", filepath); |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | gettimeofday(&begin, NULL); |
| 41 | for (i = 0; i < max; i++) |
| 42 | { |
| 43 | HTTP_HDR_REQ* hdr_req = http_hdr_req_new(); |
| 44 | |
| 45 | if (acl_vstream_fseek(fp, 0, SEEK_SET) < 0) |
| 46 | { |
| 47 | printf("fseek error\r\n"); |
| 48 | break; |
| 49 | } |
| 50 | if ((ret = http_hdr_req_get_sync(hdr_req, fp, 0)) < 0) |
| 51 | { |
| 52 | http_hdr_req_free(hdr_req); |
| 53 | printf("get header error: %d\r\n", ret); |
| 54 | break; |
| 55 | } |
| 56 | if (http_hdr_req_parse(hdr_req) < 0) |
| 57 | { |
| 58 | printf("parse error\r\n"); |
| 59 | http_hdr_req_free(hdr_req); |
| 60 | break; |
| 61 | } |
| 62 | |
| 63 | http_hdr_req_free(hdr_req); |
| 64 | |
| 65 | if (i % 1000 == 0) |
| 66 | { |
| 67 | char line[64]; |
| 68 | snprintf(line, sizeof(line), "total: %d, curr: %d", max, i); |
| 69 | ACL_METER_TIME(line); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | gettimeofday(&end, NULL); |
| 74 | n = stamp_sub(&end, &begin); |
| 75 | |
| 76 | printf("total: %d, spent: %0.2f, speed: %0.2f\r\n", |
| 77 | max, n, (max * 1000) /(n > 0 ? n : 1)); |
| 78 | |
| 79 | acl_vstream_close(fp); |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | static int header_read(const char* filepath, int max) |
no test coverage detected
searching dependent graphs…