| 5 | static int __dlen = 100; |
| 6 | |
| 7 | static 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 | |
| 50 | static void* thread_read(void* ctx) |
| 51 | { |