2 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
27 #ifndef __DISPATCH_BENCHMARK__
28 #define __DISPATCH_BENCHMARK__
30 #ifndef __DISPATCH_INDIRECT__
31 #error "Please #include <dispatch/private.h> instead of this file directly."
32 #include <dispatch/base.h> // for HeaderDoc
38 * @function dispatch_benchmark
41 * Count the average number of cycles a given block takes to execute.
44 * The number of times to serially execute the given block.
47 * The block to execute.
50 * The approximate number of cycles the block takes to execute.
53 * This function is for debugging and performance analysis work. For the best
54 * results, pass a high count value to dispatch_benchmark(). When benchmarking
55 * concurrent code, please compare the serial version of the code against the
56 * concurrent version, and compare the concurrent version on different classes
57 * of hardware. Please look for inflection points with various data sets and
58 * keep the following facts in mind:
60 * 1) Code bound by computational bandwidth may be inferred by proportional
61 * changes in performance as concurrency is increased.
62 * 2) Code bound by memory bandwidth may be inferred by negligible changes in
63 * performance as concurrency is increased.
64 * 3) Code bound by critical sections may be inferred by retrograde changes in
65 * performance as concurrency is increased.
66 * 3a) Intentional: locks, mutexes, and condition variables.
67 * 3b) Accidental: unrelated and frequently modified data on the same
71 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
72 DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
74 dispatch_benchmark(size_t count
, void (^block
)(void));
77 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
78 DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
80 dispatch_benchmark_f(size_t count
, void *ctxt
, void (*func
)(void *));