--- /dev/null
+
+//#define L4
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#ifdef L4
+
+#include <l4/util/rdtsc.h>
+#include <l4/sys/kip.h>
+#include <l4/re/env.h>
+
+#endif//L4
+
+#define WORKSET_SIZE (6*1024*1024)
+//#define ALL_WORKSETS_BENCH
+
+struct s {
+ int dummy[56];
+ struct s *ptr;
+};
+
+struct s array[0x1000000/sizeof(struct s)];
+#define REPEATS (0x20000000)
+
+static __inline__ uint64_t rdtsc(void)
+{
+ uint32_t a, d;
+ //asm("cpuid");
+ asm volatile("rdtsc" : "=a" (a), "=d" (d));
+
+ return (((uint64_t)a) | (((uint64_t)d) << 32));
+}
+
+int main(int argc, char *argv[])
+{
+
+ unsigned int size;
+#ifdef ALL_WORKSETS_BENCH
+ for (size = 1024; size <= sizeof(array); size *= 2)
+#else //!ALL_WORKSETS_BENCH
+ size = WORKSET_SIZE;
+ if (argc - 1) {
+ char * nxt_cr;
+ size = strtoul(argv[1], &nxt_cr, 0);
+ }
+ while (1)
+#endif
+ {
+ unsigned int i;
+ for (i=0; i < size / sizeof(array[0]); i++)
+ array[i].ptr = &array[i+1];
+ array[ size / sizeof(array[0]) - 1].ptr = &array[0];
+
+ i = REPEATS;
+ volatile struct s *p = &array[0];
+ uint64_t tic, tac;
+ tic = rdtsc();
+ while (i--) {
+ p = p->ptr;
+ // printf("%p\n", p);
+ }
+ tac = rdtsc();
+ printf("%d %llu\n", size, (tac - tic) / REPEATS);
+ fflush(stdout);
+ }
+ return 0;
+}