]> git.saurik.com Git - apple/libdispatch.git/blame - man/dispatch_benchmark.3
libdispatch-228.23.tar.gz
[apple/libdispatch.git] / man / dispatch_benchmark.3
CommitLineData
0ab74447
A
1.\" Copyright (c) 2008-2009 Apple Inc. All rights reserved.
2.Dd May 1, 2009
3.Dt dispatch_benchmark 3
4.Os Darwin
5.Sh NAME
6.Nm dispatch_benchmark
7.Nd Measures block execution time
8.Sh SYNOPSIS
9.Fd #include <dispatch/dispatch.h>
10.Ft uint64_t
11.Fo dispatch_benchmark
12.Fa "size_t count" "void (^block)(void)"
13.Fc
e85f4437
A
14.Ft uint64_t
15.Fo dispatch_benchmark_f
16.Fa "size_t count" "void *context" "void (*function)(void *)"
17.Fc
0ab74447
A
18.Sh DESCRIPTION
19The
20.Fn dispatch_benchmark
21function executes the given
22.Fa block
23multiple times according to the
24.Fa count
25variable and then returns the average number of nanoseconds per execution.
26This function is for debugging and performance analysis work.
27For the best
28results, pass a high count value to
29.Fn dispatch_benchmark .
30When benchmarking concurrent code, please compare the
31serial version of the code against the concurrent version, and compare the
32concurrent version on different classes of hardware.
33Please look for inflection
34points with various data sets and keep the following facts in mind:
35.Pp
36.Bl -bullet -offset indent -compact
37.It
38Code bound by computational bandwidth may be inferred by proportional
39changes in performance as concurrency is increased.
40.It
41Code bound by memory bandwidth may be inferred by negligible changes in
42performance as concurrency is increased.
43.It
44Code bound by critical sections may be inferred by retrograde changes in
45performance as concurrency is increased.
46.Bl -bullet -offset indent -compact
47.It
48Intentional: locks, mutexes, and condition variables.
49.It
50Accidental: unrelated and frequently modified data on the same cache-line.
51.El
52.El
53.Sh RETURN VALUE
54The
55.Fn dispatch_benchmark
56function returns the average number of nanoseconds the given block takes to
57execute.
58.Sh SEE ALSO
59.Xr dispatch 3