| 20 | |
| 21 | protected: |
| 22 | void* run() |
| 23 | { |
| 24 | acl::string name; |
| 25 | char value[128]; |
| 26 | |
| 27 | memset(value, 'X', sizeof(value)); |
| 28 | value[sizeof(value) - 1] = 0; |
| 29 | |
| 30 | printf(">>> count: %d\r\n", count_); |
| 31 | |
| 32 | struct timeval begin; |
| 33 | gettimeofday(&begin, NULL); |
| 34 | |
| 35 | for (int i = 0; i < count_; i++) |
| 36 | { |
| 37 | name.format("tid_%lu_%d", thread_id(), i); |
| 38 | if (sess_->set(name.c_str(), value) == false) |
| 39 | { |
| 40 | printf("set error, name: %s\r\n", name.c_str()); |
| 41 | break; |
| 42 | } |
| 43 | |
| 44 | const char* ptr = sess_->get(name.c_str()); |
| 45 | if (ptr == NULL || *ptr == 0) |
| 46 | { |
| 47 | printf("get error, name: %s\r\n", name.c_str()); |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | if (strcasecmp(ptr, value) != 0) |
| 52 | { |
| 53 | printf("invalid result\r\n"); |
| 54 | break; |
| 55 | } |
| 56 | |
| 57 | if (sess_->del(name.c_str()) == false) |
| 58 | { |
| 59 | printf("del error, name: %s\r\n", name.c_str()); |
| 60 | break; |
| 61 | } |
| 62 | |
| 63 | if (i < 10) |
| 64 | printf("test name: %s ok\r\n", name.c_str()); |
| 65 | if (i % 1000 == 0) |
| 66 | { |
| 67 | char info[128]; |
| 68 | acl::safe_snprintf(info, sizeof(info), |
| 69 | "benchmark: %d", i); |
| 70 | acl::meter_time(__FILE__, __LINE__, info); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | struct timeval end; |
| 75 | gettimeofday(&end, NULL); |
| 76 | |
| 77 | double inter = util::stamp_sub(&end, &begin); |
| 78 | printf("total: %d, spent: %0.2f ms, speed: %0.2f\r\n", |
| 79 | count_, inter, (count_ * 1000) /(inter > 0 ? inter : 1)); |
nothing calls this directly
no test coverage detected