blob: 26a638ba12ddcba918d05996812c1cdce029a9b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <al/lib.h>
#include <nnwt/common.h>
#include <nnwt/thread.h>
#include <nnwt/time.h>
#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;
}
|