| 81 | } |
| 82 | |
| 83 | static int header_read(const char* filepath, int max) |
| 84 | { |
| 85 | struct timeval begin, end; |
| 86 | double n; |
| 87 | ACL_VSTREAM* fp; |
| 88 | char line[1024]; |
| 89 | int i; |
| 90 | |
| 91 | fp = acl_vstream_fopen(filepath, O_RDONLY, 0600, 8192); |
| 92 | if (fp == NULL) |
| 93 | { |
| 94 | printf("open file %s error\r\n", filepath); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | gettimeofday(&begin, NULL); |
| 99 | for (i = 0; i < max; i++) |
| 100 | { |
| 101 | if (acl_vstream_fseek(fp, 0, SEEK_SET) < 0) |
| 102 | { |
| 103 | printf("fseek error\r\n"); |
| 104 | break; |
| 105 | } |
| 106 | while (1) |
| 107 | { |
| 108 | if (acl_vstream_gets_nonl(fp, line, sizeof(line)) == ACL_VSTREAM_EOF) |
| 109 | break; |
| 110 | } |
| 111 | |
| 112 | if (i % 1000 == 0) |
| 113 | { |
| 114 | snprintf(line, sizeof(line), "total: %d, curr: %d", max, i); |
| 115 | ACL_METER_TIME(line); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | gettimeofday(&end, NULL); |
| 120 | n = stamp_sub(&end, &begin); |
| 121 | |
| 122 | printf("total: %d, spent: %0.2f, speed: %0.2f\r\n", |
| 123 | max, n, (max * 1000) /(n > 0 ? n : 1)); |
| 124 | |
| 125 | acl_vstream_close(fp); |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static int header_parse(const char* filepath, int max) |
| 130 | { |
no test coverage detected
searching dependent graphs…