tests: benchmark: use cpu-bound workload, calculate average and std.dev.
[deliverable/lttng-ust.git] / tests / benchmark / bench.c
index bc6a389742de0bf89cf376c2b67419565fa04230..77f53a1532f9a977d149acde14c95974be0a2889 100644 (file)
@@ -2,6 +2,22 @@
  * bench.c
  *
  * LTTng Userspace Tracer (UST) - benchmark tool
+ *
+ * Copyright 2010 - Douglas Santos <douglas.santos@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _GNU_SOURCE
 #include <stdlib.h>
 #include <unistd.h>
 #include <sched.h>
-#include <ust/marker.h>
 #include <time.h>
+#include <urcu/compiler.h>
+
+#ifdef TRACING
+#define TRACEPOINT_DEFINE
+#include "ust_tests_benchmark.h"
+#endif
 
 static int nr_cpus;
 static unsigned long nr_events;
 
 void do_stuff(void)
 {
-       int v;
-       FILE *file;
-
-       v = 1;
-
-       file = fopen("/dev/null", "a");
-       fprintf(file, "%d", v);
-       fclose(file);
-       time(NULL);
-
-#ifdef MARKER
-       trace_mark(ust, event, "event %d", v);
+       int i;
+#ifdef TRACING
+       int v = 50;
 #endif
 
+       for (i = 0; i < 100; i++)
+               cmm_barrier();
+#ifdef TRACING
+       tracepoint(ust_tests_benchmark, tpbench, v);
+#endif
 }
 
-
 void *function(void *arg)
 {
        unsigned long i;
 
-       for(i = 0; i < nr_events; i++) {
+       for (i = 0; i < nr_events; i++) {
                do_stuff();
        }
        return NULL;
This page took 0.0318 seconds and 5 git commands to generate.