blob: 46f137912967c37c360750c30e72bdf61c1b7ebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <pthread.h>
#include <string.h>
#include <err.h>
#include "bench.h"
static char name[] = "Mutex Lock/Unlock, No Contention";
static char doc[] =
"\tThis is the time interval needed to call pthread_mutex_lock()\n"
"\tfollowed immediately by pthread_mutex_unlock() on a mutex that\n"
"\tis unowned and which is only being used by the thread doing\n"
"\tthe test.";
int
main() {
pthread_mutex_t m;
bench_t b;
bench_init(&b, name, doc, "from lock to unlock inclusive");
bench_header(&b);
pthread_mutex_init(&m, NULL);
bench_amortize(&b, BENCH_LOOPS) {
pthread_mutex_lock(&m);
pthread_mutex_unlock(&m);
}
bench_report(&b);
exit(0);
}
|