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

Function thread_write

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

Source from the content-addressed store, hash-verified

78}
79
80static void* thread_write(void* ctx)
81{
82 acl::socket_stream* conn = (acl::socket_stream*) ctx;
83 acl::string buf;
84
85 int i;
86 for (i = 0; i < __dlen; i++)
87 buf += 'X';
88 buf += "\r\n";
89
90 struct timeval begin;
91 gettimeofday(&begin, NULL);
92
93 for (i = 0; i < __max; i++)
94 {
95 if (conn->write(buf) == -1)
96 {
97 printf("write to client finish!\r\n");
98 break;
99 }
100 }
101
102 struct timeval end;
103 gettimeofday(&end, NULL);
104
105 double n = util::stamp_sub(&end, &begin);
106 printf("total write: %d, spent: %0.2f ms, speed: %0.2f\r\n",
107 i, n, (i * 1000) /(n > 0 ? n : 1));
108
109 return NULL;
110}
111
112static void usage(const char* procname)
113{

Callers

nothing calls this directly

Calls 3

gettimeofdayFunction · 0.50
stamp_subFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…