File: benchmark.h

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (89 lines) | stat: -rw-r--r-- 2,907 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
 *
 * @APPLE_APACHE_LICENSE_HEADER_START@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @APPLE_APACHE_LICENSE_HEADER_END@
 */

/*
 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
 * which are subject to change in future releases of Mac OS X. Any applications
 * relying on these interfaces WILL break.
 */

#ifndef __DISPATCH_BENCHMARK__
#define __DISPATCH_BENCHMARK__

#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/private.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif

DISPATCH_ASSUME_NONNULL_BEGIN

__BEGIN_DECLS

/*!
 * @function dispatch_benchmark
 *
 * @abstract
 * Count the average number of cycles a given block takes to execute.
 *
 * @param count
 * The number of times to serially execute the given block.
 *
 * @param block
 * The block to execute.
 *
 * @result
 * The approximate number of cycles the block takes to execute.
 *
 * @discussion
 * This function is for debugging and performance analysis work. For the best
 * results, pass a high count value to dispatch_benchmark(). When benchmarking
 * concurrent code, please compare the serial version of the code against the
 * concurrent version, and compare the concurrent version on different classes
 * of hardware. Please look for inflection points with various data sets and
 * keep the following facts in mind:
 *
 * 1) Code bound by computational bandwidth may be inferred by proportional
 *    changes in performance as concurrency is increased.
 * 2) Code bound by memory bandwidth may be inferred by negligible changes in
 *    performance as concurrency is increased.
 * 3) Code bound by critical sections may be inferred by retrograde changes in
 *    performance as concurrency is increased.
 * 3a) Intentional: locks, mutexes, and condition variables.
 * 3b) Accidental: unrelated and frequently modified data on the same
 *     cache-line.
 */
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
uint64_t
dispatch_benchmark(size_t count, dispatch_block_t block);
#endif

API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
uint64_t
dispatch_benchmark_f(size_t count, void *_Nullable ctxt,
		dispatch_function_t func);

__END_DECLS

DISPATCH_ASSUME_NONNULL_END

#endif