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

Function handle_connection

lib_acl_cpp/samples/benchmark/client/main.cpp:7–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5static int __dlen = 100;
6
7static void handle_connection(acl::socket_stream& conn)
8{
9 acl::string rbuf, wbuf;
10
11 for (int i = 0; i < __dlen; i++)
12 wbuf += 'X';
13 wbuf += "\r\n";
14
15 struct timeval begin;
16 gettimeofday(&begin, NULL);
17
18 for (int i = 0; i < __max; i++)
19 {
20 if (conn.write(wbuf) == -1)
21 {
22 printf("write to server error\r\n");
23 break;
24 }
25
26 if (conn.gets(rbuf) == false)
27 {
28 printf("readline from server error\r\n");
29 break;
30 }
31 if (i < 10 && !rbuf.empty())
32 printf("readline: %s\r\n", rbuf.c_str());
33
34 if (i % 1000 == 0)
35 {
36 char tmp[64];
37 snprintf(tmp, sizeof(tmp), "total: %d, curr: %d", __max, i);
38 ACL_METER_TIME(tmp);
39 }
40 }
41
42 struct timeval end;
43 gettimeofday(&end, NULL);
44
45 double n = util::stamp_sub(&end, &begin);
46 printf("total get: %d, spent: %0.2f ms, speed: %0.2f\r\n",
47 __max, n, (__max * 1000) /(n > 0 ? n : 1));
48}
49
50static void* thread_read(void* ctx)
51{

Callers 1

mainFunction · 0.70

Calls 6

getsMethod · 0.80
gettimeofdayFunction · 0.50
stamp_subFunction · 0.50
writeMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…