1
0
镜像来自 https://github.com/tearshark/librf.git synced 2024-10-01 15:57:07 +08:00
librf/benchmark/benchmark_async_mem.cpp
2020-03-26 17:26:39 +08:00

41 line
710 B
C++

#include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include "librf.h"
const size_t N = 2000000;
const size_t LOOP_COUNT = 50;
volatile size_t globalValue = 0;
void resumable_main_benchmark_mem(bool wait_key)
{
using namespace std::chrono;
for (size_t i = 0; i < N; ++i)
{
go[=]()->resumef::generator_t<size_t>
{
for (size_t k = 0; k < LOOP_COUNT; ++k)
{
globalValue += i * k;
co_yield k;
}
co_return 0;
};
}
resumef::this_scheduler()->run_until_notask();
if (wait_key)
{
std::cout << "press any key to continue." << std::endl;
(void)getchar();
}
}
//clang : 平均 210字节
//msvc : 平均600字节