diff options
author | hiramatu <hiramatu> | 2007-09-27 16:28:28 +0000 |
---|---|---|
committer | hiramatu <hiramatu> | 2007-09-27 16:28:28 +0000 |
commit | ff0dba8fb7c752a10d64258d3cc1350893139929 (patch) | |
tree | f80ecb5a1ab79d46ad9c18ad42abd1f473026f16 /testsuite/systemtap.samples/gtod.c | |
parent | 5e4c160908b88e1272ec09f2c88d7612ce82b7c8 (diff) | |
download | systemtap-steved-ff0dba8fb7c752a10d64258d3cc1350893139929.tar.gz systemtap-steved-ff0dba8fb7c752a10d64258d3cc1350893139929.tar.xz systemtap-steved-ff0dba8fb7c752a10d64258d3cc1350893139929.zip |
2007-09-27 Masami Hiramatsu <mhiramat@redhat.com>
PR3916
* systemtap.sample/gtod.*: New test for gettimeofday accuracy.
Diffstat (limited to 'testsuite/systemtap.samples/gtod.c')
-rw-r--r-- | testsuite/systemtap.samples/gtod.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <sys/time.h> +#include <unistd.h> + +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; +} + |