sysperf - Add tests for clock_gettime(CLOCK_*_FAST...) modes
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Aug 2012 07:43:58 +0000 (00:43 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Aug 2012 07:43:58 +0000 (00:43 -0700)
* Add tests for some of the new clock_gettime() modes.

test/sysperf/Makefile
test/sysperf/syscall6.c [new file with mode: 0644]
test/sysperf/syscall7.c [new file with mode: 0644]

index 34cbb78..20a7800 100644 (file)
@@ -2,7 +2,7 @@
 # $DragonFly: src/test/sysperf/Makefile,v 1.17 2008/05/09 15:49:42 dillon Exp $
 #
 
-TARGETS=/tmp/sc1 /tmp/sc2 /tmp/sc3 /tmp/sc4 /tmp/sc5 \
+TARGETS=/tmp/sc1 /tmp/sc2 /tmp/sc3 /tmp/sc4 /tmp/sc5 /tmp/sc6 /tmp/sc7 \
        /tmp/loop1 /tmp/loop2 /tmp/loop3 /tmp/loop4 \
        /tmp/call1 /tmp/call2 /tmp/call3 /tmp/cmp \
        /tmp/mt2 /tmp/mt3 /tmp/mt4 \
@@ -43,6 +43,12 @@ all: $(TARGETS)
 /tmp/sc5: syscall5.c blib.c
        $(CC) $(CFLAGS) syscall5.c blib.c -o /tmp/sc5
 
+/tmp/sc6: syscall6.c blib.c
+       $(CC) $(CFLAGS) syscall6.c blib.c -o /tmp/sc6
+
+/tmp/sc7: syscall7.c blib.c
+       $(CC) $(CFLAGS) syscall7.c blib.c -o /tmp/sc7
+
 /tmp/fork1: fork1.c blib.c
        $(CC) $(CFLAGS) fork1.c blib.c -o /tmp/fork1
 
diff --git a/test/sysperf/syscall6.c b/test/sysperf/syscall6.c
new file mode 100644 (file)
index 0000000..5fc2b14
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * syscall1.c
+ *
+ * $DragonFly: src/test/sysperf/syscall5.c,v 1.1 2005/03/28 03:13:24 dillon Exp $
+ */
+
+#include "blib.h"
+
+int
+main(int ac, char **av)
+{
+    long long count = 0;
+    long long max;
+    int j;
+    struct timeval tv;
+
+    printf("timing standard gettimeofday() syscall\n");
+
+    start_timing();
+    while (stop_timing(0, NULL) == 0) {
+       for (j = 0; j < 100; ++j)
+           gettimeofday(&tv, NULL);
+       count += 100;
+    }
+    max = count;
+    start_timing();
+    for (count = 0; count < max; count += 100) {
+       for (j = 0; j < 100; ++j)
+           gettimeofday(&tv, NULL);
+    }
+    stop_timing(count, "gettimeofday()");
+    return(0);
+}
diff --git a/test/sysperf/syscall7.c b/test/sysperf/syscall7.c
new file mode 100644 (file)
index 0000000..e2e53f9
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * syscall1.c
+ *
+ * $DragonFly: src/test/sysperf/syscall5.c,v 1.1 2005/03/28 03:13:24 dillon Exp $
+ */
+
+#include "blib.h"
+
+int
+main(int ac, char **av)
+{
+    long long count = 0;
+    long long max;
+    struct timespec ts;
+    int j;
+
+    printf("timing standard clock_gettime() syscall\n");
+
+    start_timing();
+    while (stop_timing(0, NULL) == 0) {
+       for (j = 0; j < 100; ++j)
+           clock_gettime(CLOCK_REALTIME_FAST, &ts);
+       count += 100;
+    }
+    max = count;
+    start_timing();
+    for (count = 0; count < max; count += 100) {
+       for (j = 0; j < 100; ++j)
+           clock_gettime(CLOCK_REALTIME_FAST, &ts);
+    }
+    stop_timing(count, "getuid()");
+    return(0);
+}