|
1234567891011121314151617181920212223242526272829303132333435363738 |
-
- #include <chrono>
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <thread>
-
- #include "librf.h"
-
- const size_t N = 10000000;
- const size_t LOOP_COUNT = 100;
-
- volatile size_t globalValue = 0;
-
- void resumable_main_benchmark_mem()
- {
- 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();
- std::cout << "press any key to continue." << std::endl;
- (void)_getch();
- }
-
- //clang : 平均 210字节
- //msvc : 平均600字节
|