| 30 | |
| 31 | template <template <class, class> class OC> |
| 32 | void *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 | |
| 55 | template <template <class, class> class OC> |
| 56 | void test_objcache(OC<std::string, std::string *> &oc, const char *name) { |