ittapi/collection_control.rs
1/// Run the application without collecting data.
2///
3/// VTune Profiler reduces the overhead of collection, by collecting only
4/// critical information, such as thread and process creation.
5///
6/// # Effects
7///
8/// Pausing the data collection has the following effects:
9///
10/// - Data collection is paused for the whole program, not only within the current thread.
11/// - Some runtime analysis overhead reduction.
12///
13/// The following APIs are *not* affected by pausing the data collection:
14///
15/// - Domain API
16/// - String Handle API
17/// - Thread Naming API
18///
19/// The following APIs are affected by pausing the data collection. Data is not
20/// collected for these APIs while in paused state:
21///
22/// - Task API
23/// - Frame API
24/// - Event API
25/// - User-Defined Synchronization API
26///
27/// See the [Collection Control API] for more details.
28///
29/// # Example
30///
31/// ```
32/// ittapi::pause();
33/// // Do initialization work here
34/// ittapi::resume();
35/// // Do profiling work here
36/// ittapi::pause();
37/// // Do finalization work here
38/// ```
39///
40/// [Collection Control API]: https://www.intel.com/content/www/us/en/develop/documentation/vtune-help/top/api-support/instrumentation-and-tracing-technology-apis/instrumentation-tracing-technology-api-reference/collection-control-api.html
41pub fn pause() {
42 if let Some(pause_fn) = unsafe { ittapi_sys::__itt_pause_ptr__3_0 } {
43 unsafe { (pause_fn)() };
44 }
45}
46
47/// Resume data collection.
48///
49/// VTune Profiler resumes collecting all data.
50///
51/// See the [Collection Control API] for details.
52///
53/// # Example
54///
55/// See [pause#example].
56///
57/// [Collection Control API]: https://www.intel.com/content/www/us/en/develop/documentation/vtune-help/top/api-support/instrumentation-and-tracing-technology-apis/instrumentation-tracing-technology-api-reference/collection-control-api.html
58pub fn resume() {
59 if let Some(resume_fn) = unsafe { ittapi_sys::__itt_resume_ptr__3_0 } {
60 unsafe { (resume_fn)() };
61 }
62}
63
64/// Detach data collection.
65///
66/// VTune Profiler detaches all collectors from all processes. Your application
67/// continues to work but no data is collected for the running collection.
68///
69/// See the [Collection Control API] for details.
70///
71/// # Example
72///
73/// Detach behaves similarly to [pause#example].
74///
75/// [Collection Control API]: https://www.intel.com/content/www/us/en/develop/documentation/vtune-help/top/api-support/instrumentation-and-tracing-technology-apis/instrumentation-tracing-technology-api-reference/collection-control-api.html
76pub fn detach() {
77 if let Some(detach_fn) = unsafe { ittapi_sys::__itt_detach_ptr__3_0 } {
78 unsafe { (detach_fn)() };
79 }
80}