MCPcopy Create free account
hub / github.com/alibaba/async_simple / Lazy_same_read_bench

Function Lazy_same_read_bench

benchmarks/ReadFile.bench.cpp:120–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 unlink(s.c_str());
119}
120void Lazy_same_read_bench(benchmark::State &state) {
121 using namespace async_simple::coro;
122 int num = state.range(0);
123 int id = 4;
124 std::string s = std::string("test.") + std::to_string(id) + ".txt";
125 gen_file(s, id);
126 auto core_num = std::thread::hardware_concurrency();
127 SimpleExecutor e(core_num);
128 for (auto _ : state) {
129 auto f = [&s, &e, num, core_num]() -> Lazy<void> {
130 std::vector<Lazy<void>> lazy_list;
131 lazy_list.reserve(core_num);
132 for (size_t i = 0; i < core_num; ++i) {
133 lazy_list.push_back(
134 async_read_file_for(num, s, e.getIOExecutor()));
135 }
136 co_await collectAllPara(std::move(lazy_list));
137 co_return;
138 };
139 syncAwait(f().via(&e));
140 }
141 unlink(s.c_str());
142}

Callers

nothing calls this directly

Calls 10

stringFunction · 0.85
to_stringFunction · 0.85
gen_fileFunction · 0.85
async_read_file_forFunction · 0.85
collectAllParaFunction · 0.85
syncAwaitFunction · 0.85
fFunction · 0.85
viaMethod · 0.80
reserveMethod · 0.45
getIOExecutorMethod · 0.45

Tested by

no test coverage detected