MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / task

Function task

common/test/perf_objcache.cpp:32–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31template <template <class, class> class OC>
32void *task(void *arg) {
33 auto oc = (OC<std::string, std::string *> *)arg;
34 std::array<uint64_t, count> k = keys;
35 std::random_device rd;
36 std::mt19937 g(rd());
37 std::shuffle(k.begin(), k.end(), g);
38
39 auto start = std::chrono::steady_clock::now();
40 for (const auto &x : k) {
41 auto strx = std::to_string(x);
42 auto b = oc->borrow(strx, [&strx] {
43 photon::thread_usleep(1 * 1000);
44 // LOG_INFO("CTOR `", photon::now);
45 return new std::string(strx);
46 });
47 }
48 auto done = std::chrono::steady_clock::now();
49 LOG_INFO("spent ` ms",
50 std::chrono::duration_cast<std::chrono::milliseconds>(done - start)
51 .count());
52 return nullptr;
53}
54
55template <template <class, class> class OC>
56void test_objcache(OC<std::string, std::string *> &oc, const char *name) {

Callers 1

do_eventMethod · 0.50

Calls 7

shuffleFunction · 0.85
to_stringFunction · 0.50
thread_usleepFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
borrowMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected