#include #include #include #include #define DELAY 100000 #define REPEAT 21 static struct nn_thread thread; static nn_thread_result NNWT_THREADCALL test_thread(void *userdata) { (void)userdata; u64 now, diff; s64 adj; f64 start = nn_get_tick(); for (u32 iter = 0; iter < REPEAT; iter++) { now = nn_get_timestamp(); diff = (nn_get_tick() - start) * 1000000; adj = iter * DELAY - (s64)diff; al_printf("[%2u (%llu)] %fs(%s%f)\n", iter, now, diff / 1000000.0, adj >= 0 ? "+" : "", adj / 1000000.0); nn_thread_sleep(NNWT_TS_FROM_USEC(MAX(DELAY + adj, (s64)1))); } return 0; } s32 main(void) { if (!nn_common_init(NULL)) return EXIT_FAILURE; nn_thread_create(&thread, test_thread, NULL); nn_thread_join(&thread); nn_common_close(); return EXIT_SUCCESS; }