1 .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved.
3 .Dt dispatch_benchmark 3
7 .Nd Measures block execution time
9 .Fd #include <dispatch/dispatch.h>
11 .Fo dispatch_benchmark
12 .Fa "size_t count" "void (^block)(void)"
16 .Fn dispatch_benchmark
17 function executes the given
19 multiple times according to the
21 variable and then returns the average number of nanoseconds per execution.
22 This function is for debugging and performance analysis work.
24 results, pass a high count value to
25 .Fn dispatch_benchmark .
26 When benchmarking concurrent code, please compare the
27 serial version of the code against the concurrent version, and compare the
28 concurrent version on different classes of hardware.
29 Please look for inflection
30 points with various data sets and keep the following facts in mind:
32 .Bl -bullet -offset indent -compact
34 Code bound by computational bandwidth may be inferred by proportional
35 changes in performance as concurrency is increased.
37 Code bound by memory bandwidth may be inferred by negligible changes in
38 performance as concurrency is increased.
40 Code bound by critical sections may be inferred by retrograde changes in
41 performance as concurrency is increased.
42 .Bl -bullet -offset indent -compact
44 Intentional: locks, mutexes, and condition variables.
46 Accidental: unrelated and frequently modified data on the same cache-line.
51 .Fn dispatch_benchmark
52 function returns the average number of nanoseconds the given block takes to