In the memcpy operation, although it is a memory operation, but still consumes a little CPU, today tested a single thread to perform the memcpy efficiency, this result for the configuration of TCP Epoll work thread
Quantity is instructive. The following 8K-based memory fast execution memcpy, 1 threads about 1S can copy 500M, if the server bandwidth or network card to the upper limit is 1G, then network IO work thread open 2, considering the resolution of the message loss, 3 threads enough to withstand the highest hardware load.
Before I went to the test machine, the test results were:
Intel (R) Xeon (r) CPU E5405 @ 2.00GHz
Do memcpy speed:12.27 MS/MB
Each thread can do memcpy 667.645 MB
Copy Code code as follows:
#include <iostream>
#include <sys/time.h>
#include <string.h>
using namespace Std;
int main (int argc, char* argv[])
{
Long len = 8192;
int loop = 200;
char* p = new Char[len];
char* q = p;
struct timeval start, end;
Gettimeofday (&start, NULL);
for (int i =0; i < loop; ++i)
{
char* p = new Char[len];
*p = char (i);
memcpy (P, Q, Len);
delete [] p;
}
Gettimeofday (&end, NULL);
cout << "Do memcpy Speed:" << (end.tv_sec-start.tv_sec) *1000 + double (end.tv_usec-start.tv_usec)/(Len*lo op/1000/1000))/loop<< "ms/mb\n";
cout << "Each thread can do memcpy" << double (len) *loop/1000/1000/(END.TV_SEC-START.TV_SEC) + double (end.t V_USEC-START.TV_USEC)/1000/1000) << "mb\n";
}