I am writing a echoclient, as below:

Ptr!Conn conn = connect("127.0.0.1",8881);
ubyte[100] buf;
for(int i=0; i<N; i++)
{
        scope string str = format("%s",i);
        conn.write((cast(ubyte*)str.ptr)[0..str.length]);
        conn.read(buf[0..str.length]);
        n++;
}
conn.close();


When it loops about more than 100000 times,the throughput will fall from 60000request/second to 26request/second.

If the code changes a little as below:

 scope string str = format("%s",10000); //changes to a constant

It will runs normally with speed of 60000request/second. I test for 13minutes, everything seems well.



What happened when the code changes a little? Who will give an explaination,Thanks a lot?

Reply via email to