pub struct AndroidTrace { /* private fields */ }
Expand description

A handle to the available NDK tracing functions

All access is thread safe

Implementations§

source§

impl AndroidTrace

source

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

source

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.

source

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.

source

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.

source

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.

source

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.

source

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

source

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

source

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

source§

fn clone(&self) -> AndroidTrace

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AndroidTrace

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AndroidTrace

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.