4 * LTTng Userspace Tracer (UST) - benchmark tool
13 #include <ust/marker.h>
16 static unsigned long nr_events
;
17 pthread_mutex_t mutex
= PTHREAD_MUTEX_INITIALIZER
;
27 lock
= pthread_mutex_lock(&mutex
);
28 file
= fopen("/tmp/bench.txt", "a");
29 fprintf(file
, "%d", v
);
31 lock
= pthread_mutex_unlock(&mutex
);
34 trace_mark(ust
, event
, "event %d", v
);
40 void *function(void *arg
)
44 for(i
= 0; i
< nr_events
; i
++) {
51 void usage(char **argv
) {
52 printf("Usage: %s nr_cpus nr_events\n", argv
[0]);
56 int main(int argc
, char **argv
)
66 nr_cpus
= atoi(argv
[1]);
67 printf("using %d processor(s)\n", nr_cpus
);
69 nr_events
= atol(argv
[2]);
70 printf("using %ld events per cpu\n", nr_events
);
72 pthread_t thread
[nr_cpus
];
73 for (i
= 0; i
< nr_cpus
; i
++) {
74 if (pthread_create(&thread
[i
], NULL
, function
, NULL
)) {
75 fprintf(stderr
, "thread create %d failed\n", i
);
80 for (i
= 0; i
< nr_cpus
; i
++) {
81 if (pthread_join(thread
[i
], &retval
)) {
82 fprintf(stderr
, "thread join %d failed\n", i
);