summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-09-18 19:47:51 +0000
committerTavian Barnes <tavianator@gmail.com>2009-09-18 19:47:51 +0000
commite2fa7956b87c23a8229926f39a3863ecd4d4752a (patch)
tree89008fd214693cf8b5df22b9b492fcd3f394e0cb /tests
parent25052f0997c75f91846511041cf4eeb20959ae96 (diff)
downloadlibsandglass-e2fa7956b87c23a8229926f39a3863ecd4d4752a.tar.xz
Add timespec helper routines.
Diffstat (limited to 'tests')
-rw-r--r--tests/introspective-system.c21
1 files changed, 10 insertions, 11 deletions
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 @@
* <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include <sandglass.h>
+#include "../src/sandglass_impl.h"
+#include "../src/sandglass.h"
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
@@ -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;
}