profiling: simple test
authorRonald G. Minnich <rminnich@google.com>
Wed, 14 May 2014 21:21:46 +0000 (14:21 -0700)
committerRonald G. Minnich <rminnich@google.com>
Wed, 14 May 2014 21:22:34 +0000 (14:22 -0700)
vcore.h has inlines for reading resume and total times for the
current vcpu. prot_test will do simple tests to test those values.
prof_test is not running as an mcp currently so prints nothing useful.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
tests/prof_test.c [new file with mode: 0644]
user/parlib/include/vcore.h

diff --git a/tests/prof_test.c b/tests/prof_test.c
new file mode 100644 (file)
index 0000000..49d48e5
--- /dev/null
@@ -0,0 +1,49 @@
+/* Copyright (c) 2013 The Regents of the University of California
+ * Barret Rhoden <brho@cs.berkeley.edu>
+ * See LICENSE for details.
+ *
+ * lock_test: microbenchmark to measure different styles of spinlocks. */
+
+#include <stdio.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <math.h>
+#include <argp.h>
+
+#include <tsc-compat.h>
+#include <measure.h>
+
+/* OS dependent #incs */
+#include <parlib.h>
+#include <vcore.h>
+#include <timing.h>
+#include <spinlock.h>
+#include <mcs.h>
+#include <arch/arch.h>
+#include <event.h>
+
+int main(int argc, char** argv)
+{
+       volatile int i;
+       uint64_t ns;
+
+       uint64_t resume, total;
+       resume = __procinfo.vcoremap[vcore_id()].resume;
+       total = __procinfo.vcoremap[vcore_id()].total;
+       for(i = 0; i < 1048576*1024; i++)
+               ;
+       ns = tsc2nsec(read_tsc());
+       printf("resume %p total %p ns %p\n", resume, total, ns);
+       resume = __procinfo.vcoremap[vcore_id()].resume;
+       total = __procinfo.vcoremap[vcore_id()].total;
+       ns = tsc2nsec(read_tsc());
+       printf("resume %p total %p ns %p\n", resume, total, ns);
+       resume = __procinfo.vcoremap[vcore_id()].resume;
+       total = __procinfo.vcoremap[vcore_id()].total;
+       for(i = 0; i < 1048576*1024; i++)
+               ;
+       ns = tsc2nsec(read_tsc());
+       printf("resume %p total %p ns %p\n", resume, total, ns);
+}
index d09313d..4cc2d97 100644 (file)
@@ -157,6 +157,16 @@ static inline void set_vcpd_tls_desc(uint32_t vcoreid, void *tls_desc)
        __procdata.vcore_preempt_data[vcoreid].vcore_tls_desc = (uintptr_t)tls_desc;
 }
 
+static inline uint64_t vcore_resume(int vcore)
+{
+       return __procinfo.vcoremap[vcore].resume;
+}
+
+static inline uint64_t vcore_total(int vcore)
+{
+       return __procinfo.vcoremap[vcore].total;
+}
+
 #ifndef __PIC__
 
 #define begin_safe_access_tls_vars()