You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2013/07/15 16:54:12 UTC

[lucy-commits] git commit: refs/heads/method-dispatch-benchmark - Add simulation of an inlined method.

Updated Branches:
  refs/heads/method-dispatch-benchmark 1ee9b2d16 -> e2604e9e8


Add simulation of an inlined method.

Simulate an inlined method by looping around the work actually done by
the method.

Thwart compiler optimization by allowing an override of the number of
iterations via a command line argument.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e2604e9e
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e2604e9e
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e2604e9e

Branch: refs/heads/method-dispatch-benchmark
Commit: e2604e9e822de2739b0d71e0a86ea3ed24fb3efc
Parents: 1ee9b2d
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sun Jun 23 16:53:32 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Jul 15 07:51:35 2013 -0700

----------------------------------------------------------------------
 devel/benchmarks/method_dispatch/exe.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e2604e9e/devel/benchmarks/method_dispatch/exe.c
----------------------------------------------------------------------
diff --git a/devel/benchmarks/method_dispatch/exe.c b/devel/benchmarks/method_dispatch/exe.c
index 4c9c622..d696d0c 100644
--- a/devel/benchmarks/method_dispatch/exe.c
+++ b/devel/benchmarks/method_dispatch/exe.c
@@ -6,8 +6,9 @@
 #include "dso.h"
 
 #define CPUFREQ    UINT64_C(2800000000)
-#define ITERATIONS UINT64_C(1000000000)
 #define NOINLINE   __attribute__ ((noinline))
+uint64_t iterations;
+#define ITERATIONS iterations
 
 static inline method_t
 Obj_Hello_PTR(obj_t *obj) {
@@ -92,6 +93,13 @@ call_with_thunk(obj_t *obj) {
 }
 #endif
 
+void
+loop_with_simulated_inline(obj_t *obj) {
+    for (uint64_t i = 0; i < ITERATIONS; ++i) {
+        obj->value++;
+    }
+}
+
 static void
 bench(method_t fn, const char *name) {
     obj_t *obj = Obj_new();
@@ -116,7 +124,13 @@ bench(method_t fn, const char *name) {
 }
 
 int
-main() {
+main(int argc, char **argv) {
+    if (argc > 1) {
+        iterations = strtoll(argv[1], NULL, 10);
+    }
+    else {
+        iterations = UINT64_C(1000000000);
+    }
     bootstrap();
 
     bench(loop_with_method_ptr, "method ptr loop");
@@ -130,6 +144,7 @@ main() {
     bench(call_with_thunk, "thunk");
     bench(call_with_thunk_ptr, "thunk ptr");
 #endif
+    bench(loop_with_simulated_inline, "simulated inline");
 
     return 0;
 }