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

Function run

lib_acl/samples/udp/client/main.cpp:114–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114static void run(const char *local_addr, const char *peer_addr,
115 int count, int dlen, int inter, int need_read, int mio_on, int quit)
116{
117 int i;
118 double spent;
119 char data[4096];
120 struct timeval begin, end;
121 SOCK_UDP *sock = udp_client_open(local_addr, peer_addr);
122
123 (void) quit;
124
125 if (sock == NULL) {
126 printf("open_sock error!\r\n");
127 return;
128 }
129
130 if (dlen > (int) sizeof(data) - 1)
131 dlen = (int) sizeof(data) - 1;
132 for (i = 0; i < dlen; i++)
133 data[i] = 'X';
134 data[dlen] = 0;
135
136 gettimeofday(&begin, NULL);
137
138 if (mio_on)
139 i = mio(sock, peer_addr, dlen, count, inter, need_read);
140 else
141 i = sio(sock, data, dlen, count, inter, need_read);
142
143 gettimeofday(&end, NULL);
144 spent = stamp_sub(&end, &begin);
145
146 printf("thread: %lu, total: %d, curr: %d, spent: %.2f, speed: %.2f\r\n",
147 (unsigned long) acl_pthread_self(), count, i, spent,
148 (i * 1000) / (spent > 1 ? spent : 1));
149
150 printf("thread: %lu, peer addr: %s\r\n",
151 (unsigned long) acl_pthread_self(), peer_addr);
152
153 udp_close(sock);
154}
155
156typedef struct {
157 char local[64];

Callers 2

thread_runFunction · 0.70
mainFunction · 0.70

Calls 7

udp_client_openFunction · 0.85
acl_pthread_selfFunction · 0.85
udp_closeFunction · 0.85
mioFunction · 0.70
sioFunction · 0.70
stamp_subFunction · 0.70
gettimeofdayFunction · 0.50

Tested by

no test coverage detected