1 #include <glib.h>
2
3 static void
4 test_bitlocks (void)
5 {
6 guint64 start = g_get_monotonic_time ();
7 gint lock = 0;
8 guint i;
9 guint n_iterations;
10
11 n_iterations = g_test_perf () ? 100000000 : 1;
12
13 for (i = 0; i < n_iterations; i++)
14 {
15 g_bit_lock (&lock, 0);
16 g_bit_unlock (&lock, 0);
17 }
18
19 {
20 gdouble elapsed;
21 gdouble rate;
22
23 elapsed = g_get_monotonic_time () - start;
24 elapsed /= 1000000;
25 rate = n_iterations / elapsed;
26
27 g_test_maximized_result (rate, "iterations per second");
28 }
29 }
30
31 int
32 main (int argc, char **argv)
33 {
34 g_test_init (&argc, &argv, NULL);
35
36 g_test_add_func ("/bitlock/performance/uncontended", test_bitlocks);
37
38 return g_test_run ();
39 }