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

Function header_read

lib_protocol/samples/http/header/main.c:83–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static 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
129static int header_parse(const char* filepath, int max)
130{

Callers 1

mainFunction · 0.85

Calls 6

acl_vstream_fopenFunction · 0.85
acl_vstream_fseekFunction · 0.85
acl_vstream_gets_nonlFunction · 0.85
acl_vstream_closeFunction · 0.85
stamp_subFunction · 0.70
gettimeofdayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…