1
0
mirror of https://github.com/tearshark/librf.git synced 2024-10-02 00:00:11 +08:00
librf/benchmark/benchmark_async_mem.cpp

37 lines
643 B
C++
Raw Normal View History

2017-09-24 14:36:36 +08:00

#include <chrono>
#include <iostream>
#include <string>
#include <conio.h>
#include <thread>
#include "librf.h"
const size_t N = 1000000;
2018-08-08 21:01:25 +08:00
volatile size_t globalValue = 0;
2017-09-24 14:36:36 +08:00
void resumable_main_benchmark_mem()
{
using namespace std::chrono;
2018-08-08 21:01:25 +08:00
resumef::state_t<void> st;
std::cout << sizeof(st) << " " << sizeof(resumef::promise_vt) << std::endl;
2017-09-24 14:36:36 +08:00
for (size_t i = 0; i < N; ++i)
{
2018-08-08 21:01:25 +08:00
go[=]()->resumef::future_t<size_t>
2017-09-24 14:36:36 +08:00
{
2018-08-08 21:01:25 +08:00
for (size_t k = 0; k < 10; ++k)
{
globalValue += i * k;
co_yield k;
}
return 0;
2017-09-24 14:36:36 +08:00
};
}
2017-10-01 10:33:08 +08:00
resumef::this_scheduler()->run_until_notask();
(void)_getch();
2017-09-24 14:36:36 +08:00
}