summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.samples/gtod.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2007-09-27 13:33:53 -0400
committerFrank Ch. Eigler <fche@elastic.org>2007-09-27 13:33:53 -0400
commitc4123634bf7befe9b1390265b5279d2676b20f51 (patch)
treef80ecb5a1ab79d46ad9c18ad42abd1f473026f16 /testsuite/systemtap.samples/gtod.c
parente154a2613d455f3bdf13c8aeb179c8634f1b6bf5 (diff)
parentff0dba8fb7c752a10d64258d3cc1350893139929 (diff)
downloadsystemtap-steved-c4123634bf7befe9b1390265b5279d2676b20f51.tar.gz
systemtap-steved-c4123634bf7befe9b1390265b5279d2676b20f51.tar.xz
systemtap-steved-c4123634bf7befe9b1390265b5279d2676b20f51.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Diffstat (limited to 'testsuite/systemtap.samples/gtod.c')
-rw-r--r--testsuite/systemtap.samples/gtod.c26
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;
+}
+