From ff0dba8fb7c752a10d64258d3cc1350893139929 Mon Sep 17 00:00:00 2001 From: hiramatu Date: Thu, 27 Sep 2007 16:28:28 +0000 Subject: 2007-09-27 Masami Hiramatsu PR3916 * systemtap.sample/gtod.*: New test for gettimeofday accuracy. --- testsuite/systemtap.samples/gtod.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 testsuite/systemtap.samples/gtod.c (limited to 'testsuite/systemtap.samples/gtod.c') diff --git a/testsuite/systemtap.samples/gtod.c b/testsuite/systemtap.samples/gtod.c new file mode 100644 index 00000000..abc08543 --- /dev/null +++ b/testsuite/systemtap.samples/gtod.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + int i; + struct timeval tv[100][2]; + int us = 0; + if (argc == 2) us = atoi(argv[1]); + for (i=0; i<100; i++) { + gettimeofday(&tv[i][0], NULL); + setsid(); + gettimeofday(&tv[i][1], NULL); + if (us) usleep(us); + } + for (i=0; i<100; i++) { + // change last 4 chars for correctly sorting even if the + // time stamps are completely same. + printf("%8d%06d :%02d appl\n", tv[i][0].tv_sec, tv[i][0].tv_usec, i); + printf("%8d%06d :%02d prog\n", tv[i][1].tv_sec, tv[i][1].tv_usec, i); + } + return 0; +} + -- cgit