28 template <
typename>
class MainPtr,
29 template <
typename>
class WeakPtr,
32 MainPtr<int> mainPtr(std::make_unique<int>(42));
34 std::vector<std::thread> ts;
36 for (
size_t t = 0;
t < threadCount; ++
t) {
37 ts.emplace_back([&]() {
38 WeakPtr<int> weakPtr(mainPtr);
42 for (
size_t i = 0;
i < n; ++
i) {
59 benchmark<std::shared_ptr, std::weak_ptr, 1>(n);
63 benchmark<std::shared_ptr, std::weak_ptr, 4>(n);
67 benchmark<TLMainPtr, TLWeakPtr, 1>(n);
71 benchmark<TLMainPtr, TLWeakPtr, 4>(n);
75 gflags::ParseCommandLineFlags(&argc, &argv,
true);
76 gflags::SetCommandLineOptionWithMode(
77 "bm_min_usec",
"100000", gflags::SET_FLAG_IF_DEFAULT);
int main(int argc, char **argv)
BENCHMARK(WeakPtrOneThread, n)