| 344 | } |
| 345 | |
| 346 | void coroutine_test(int& integer) |
| 347 | { |
| 348 | constexpr int stack_length = 0x200; |
| 349 | |
| 350 | BN_PROFILER_START("coroutine_disabled"); |
| 351 | |
| 352 | int disabled_result = 0; |
| 353 | |
| 354 | { |
| 355 | bn::random random; |
| 356 | unsigned last_result = 0; |
| 357 | |
| 358 | for(int i = 0; i < its; ++i) |
| 359 | { |
| 360 | unsigned new_result = random.get(); |
| 361 | unsigned result = last_result + new_result; |
| 362 | last_result = new_result; |
| 363 | disabled_result += int(result); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | BN_PROFILER_STOP(); |
| 368 | |
| 369 | BN_PROFILER_START("coroutine_std_ewram"); |
| 370 | |
| 371 | int std_ewram_result = 0; |
| 372 | |
| 373 | { |
| 374 | std_coroutine_task<ewram_allocator> task(std_coroutine_impl<ewram_allocator>(std_ewram_result)); |
| 375 | |
| 376 | while(! task.done()) |
| 377 | { |
| 378 | task(); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | BN_PROFILER_STOP(); |
| 383 | |
| 384 | BN_ASSERT(disabled_result == std_ewram_result, "Invalid std ewram coroutine"); |
| 385 | |
| 386 | BN_PROFILER_START("coroutine_std_iwram"); |
| 387 | |
| 388 | int std_iwram_result = 0; |
| 389 | |
| 390 | { |
| 391 | alignas(int) char buffer[stack_length]; |
| 392 | bn::best_fit_allocator allocator(buffer, stack_length); |
| 393 | iwram_allocator::allocator = &allocator; |
| 394 | |
| 395 | std_coroutine_task<iwram_allocator> task(std_coroutine_impl<iwram_allocator>(std_iwram_result)); |
| 396 | |
| 397 | while(! task.done()) |
| 398 | { |
| 399 | task(); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | BN_PROFILER_STOP(); |
no test coverage detected