Struct android_trace::AndroidTrace
source · pub struct AndroidTrace { /* private fields */ }
Expand description
A handle to the available NDK tracing functions
All access is thread safe
Implementations§
source§impl AndroidTrace
impl AndroidTrace
sourcepub fn new() -> Self
pub fn new() -> Self
Get a handle to all of the NDK tracing functions available on this device.
This should be expected to have a low runtime cost.
Can subsequently be used across multiple threads
sourcepub fn new_downlevel() -> Self
pub fn new_downlevel() -> Self
Get a handle to the first level of the NDK tracing functions, where available on this device.
This should be expected to have a low runtime cost.
sourcepub fn is_enabled(&self) -> Option<bool>
pub fn is_enabled(&self) -> Option<bool>
Returns Some(true) if tracing through Android Trace is enabled (and Some(false) if it is disabled). This value is not guaranteed to have the same value over time. Tracing may begin and end during execution. Note that the Android platform does not provide any non-polling method for determining whether this tracing is enabled.
If ATrace_isEnabled
is not available, returns None.
This means that none of the tracing methods will have any effect during this program execution,
and so can be skipped.
Calls ATrace_isEnabled
if available. This is only available since Android API level 23. If the api_level_23
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
Please note that api_level_23
is a default feature.
sourcepub fn begin_section(&self, section_name: &CStr)
pub fn begin_section(&self, section_name: &CStr)
Writes a tracing message to indicate that the given section of code has begun.
This should be followed by a call to Self::end_section
on the same thread, to close the
opened section.
Calls ATrace_beginSection
if available. This is only available since Android API level 23. If the api_level_23
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
Please note that api_level_23
is a default feature.
If ATrace_beginSection
is not available, this has no effect.
sourcepub fn end_section(&self)
pub fn end_section(&self)
Writes a tracing message to indicate that a given section of code has ended.
This should follow a call to Self::begin_section
on the same thread, as
this will be closing an opened section.
Calls ATrace_endSection
if available. This is only available since Android API level 23. If the api_level_23
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
Please note that api_level_23
is a default feature
If ATrace_endSection
is not available, this has no effect.
sourcepub fn begin_async_section(
&self,
section_name: &CStr,
cookie: i32
) -> Option<()>
pub fn begin_async_section( &self, section_name: &CStr, cookie: i32 ) -> Option<()>
Writes a tracing message to indicate that a given section of code has begun.
This should be followed by a call to Self::end_async_section
with the same section_name
and cookie
,
although this subsequent call can occur on any thread.
Calls ATrace_beginAsyncSection
if available. This is only available since Android API level 29. If the api_level_29
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
If ATrace_beginAsyncSection
is not available, this has no effect.
sourcepub fn end_async_section(&self, section_name: &CStr, cookie: i32) -> Option<()>
pub fn end_async_section(&self, section_name: &CStr, cookie: i32) -> Option<()>
Writes a tracing message to indicate that a given section of code has ended
This should follow a call to Self::begin_async_section
with the same section_name
and cookie
,
although this call can occur on any thread
Calls ATrace_endAsyncSection
if available. This is only available since Android API level 29. If the api_level_29
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
If ATrace_endAsyncSection
is not available, this has no effect
sourcepub fn could_use_api_level_29(&self) -> bool
pub fn could_use_api_level_29(&self) -> bool
Whether the Self::set_counter
, Self::begin_async_section
and Self::end_async_section
might do anything.
This value will be the same across multiple calls (on this AndroidTrace
instance -
see Self::new_downlevel
), and so can be used as an early-fastpath feature.
Note that you should also call Self::is_enabled
if calculating
an individual value to pass to the corresponding functions will be expensive
sourcepub fn set_counter(&self, counter_name: &CStr, value: i64) -> Option<()>
pub fn set_counter(&self, counter_name: &CStr, value: i64) -> Option<()>
Writes a trace message to indicate that the counter with the given name has the given value.
Calls ATrace_setCounter
if available. This is only available since Android API level 29. If the api_level_29
feature is not
enabled, this will attempt to access a dynamically linked version of the underlying function.
If ATrace_endAsyncSection
is not available, this has no effect
Trait Implementations§
source§impl Clone for AndroidTrace
impl Clone for AndroidTrace
source§fn clone(&self) -> AndroidTrace
fn clone(&self) -> AndroidTrace
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more