From e2fa7956b87c23a8229926f39a3863ecd4d4752a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 18 Sep 2009 19:47:51 +0000 Subject: Add timespec helper routines. --- tests/introspective-system.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tests/introspective-system.c') diff --git a/tests/introspective-system.c b/tests/introspective-system.c index 8366623..21ffa4c 100644 --- a/tests/introspective-system.c +++ b/tests/introspective-system.c @@ -18,7 +18,8 @@ * . * *************************************************************************/ -#include +#include "../src/sandglass_impl.h" +#include "../src/sandglass.h" #include #include #include @@ -29,22 +30,20 @@ main() { sandglass_t sandglass; sandglass_attributes_t attr = { SANDGLASS_INTROSPECTIVE, SANDGLASS_SYSTEM }; - struct timespec tosleep = { .tv_sec = 0, .tv_nsec = 100000000 }; + struct timespec tosleep; if (sandglass_create(&sandglass, &attr, &attr) != 0) { perror("sandglass_create()"); return EXIT_FAILURE; } - if (sandglass_begin(&sandglass) != 0) { - perror("sandglass_begin()"); - return EXIT_FAILURE; - } - while (nanosleep(&tosleep, &tosleep) != 0); - if (sandglass_elapse(&sandglass) != 0) { - perror("sandglass_elapse()"); - return EXIT_FAILURE; - } + sandglass_bench(&sandglass, { + tosleep.tv_sec = 0; + tosleep.tv_nsec = 100000000L; + sandglass_spin(&tosleep); + }); + + printf("%g\n", sandglass.grains/sandglass.resolution); return EXIT_SUCCESS; } -- cgit v1.2.3