[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2 1/2] rpcbench: Benchmark für Syscall



+ rpcbench: Mit dem Parameter sys misst rpcbench jetzt die Dauer eines
  get_tick_count-Syscalls. Das ist recht hilfreich, wenn man am
  Optimieren des Kernels verzweifeln möchte.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/rpcbench/rpcbench.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/modules/rpcbench/rpcbench.c b/src/modules/rpcbench/rpcbench.c
index f4fc41c..7b407eb 100644
--- a/src/modules/rpcbench/rpcbench.c
+++ b/src/modules/rpcbench/rpcbench.c
@@ -49,6 +49,7 @@
 void display_usage(void);
 
 int client(void);
+int syscall(void);
 void display_stats(uint32_t time, uint64_t data_size);
 
 int server(void);
@@ -72,6 +73,8 @@ int main(int argc, char* argv[])
         return client();
     } else if (strcmp(argv[1], "server") == 0) {
         return server();
+    } else if (strcmp(argv[1], "sys") == 0) {
+        return syscall();
     } else {
         display_usage();
         return -1;
@@ -128,6 +131,26 @@ int client()
     return 0;
 }
 
+int syscall(void)
+{
+    int i;
+    uint64_t total, t1, t2;
+
+    total = 0;
+    for (i = 0; i < 30; i++) {
+        asm volatile("rdtsc" : "=A" (t1));
+        get_tick_count();
+        asm volatile("rdtsc" : "=A" (t2));
+        printf("syscalls: %lld Takte\n", t2 - t1);
+        total += t2 - t1;
+    }
+    printf("syscalls: Insgesamt %lld Takte, Durchschnitt %lld\n\n",
+        total, total / 30);
+
+
+    return 0;
+}
+
 void display_stats(uint32_t time, uint64_t data_size)
 {
     printf(" %lld Bytes in %d Sekunden transportiert\n", data_size, 
-- 
1.6.0.2