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

Method run

lib_acl_cpp/samples/session/redis_session.cpp:22–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21protected:
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));

Callers

nothing calls this directly

Calls 9

safe_snprintfFunction · 0.85
meter_timeFunction · 0.85
gettimeofdayFunction · 0.50
stamp_subFunction · 0.50
formatMethod · 0.45
setMethod · 0.45
c_strMethod · 0.45
getMethod · 0.45
delMethod · 0.45

Tested by

no test coverage detected