57 printf(
"### Round: %d ###\n", index);
59 time_t begin_time = time(
nullptr);
65 time_t end_time = time(
nullptr);
67 printf(
"allocate %d coroutine, cost time: %d s, clock time: %d ms, avg: %lld ns\n",
MAX_COROUTINE_NUMBER,
68 static_cast<int>(end_time - begin_time),
CALC_MS_CLOCK(end_clock - begin_clock),
75 fprintf(stderr,
"coroutine create failed, the real number is %d\n", i);
76 fprintf(stderr,
"maybe sysconf [vm.max_map_count] extended?\n");
82 end_time = time(
nullptr);
84 printf(
"create %d coroutine, cost time: %d s, clock time: %d ms, avg: %lld ns\n",
MAX_COROUTINE_NUMBER,
85 static_cast<int>(end_time - begin_time),
CALC_MS_CLOCK(end_clock - begin_clock),
88 begin_time = end_time;
89 begin_clock = end_clock;
97 bool continue_flag =
true;
98 long long real_switch_times =
static_cast<long long>(0);
100 while (continue_flag) {
101 continue_flag =
false;
103 if (0 ==
co_arr[i]->resume()) {
104 continue_flag =
true;
110 end_time = time(
nullptr);
112 printf(
"switch %d coroutine contest %lld times, cost time: %d s, clock time: %d ms, avg: %lld ns\n",
116 begin_time = end_time;
117 begin_clock = end_clock;
121 end_time = time(
nullptr);
123 printf(
"remove %d coroutine, cost time: %d s, clock time: %d ms, avg: %lld ns\n",
MAX_COROUTINE_NUMBER,
124 static_cast<int>(end_time - begin_time),
CALC_MS_CLOCK(end_clock - begin_clock),