Skip to main content

ark_api_ffi/ffi/
profiler_v0.rs

1define_api_id!(0x8459_b1a3_a7d6_4155, "profiler-v0");
2
3use bytemuck::Pod;
4use bytemuck::Zeroable;
5
6/// `puffin::StreamInfo` minus the actual stream.
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Pod, Zeroable)]
8#[repr(C)]
9pub struct StreamMeta {
10    pub num_scopes: u64,
11    pub depth: u64,
12    pub range_ns_min: i64,
13    pub range_ns_max: i64,
14}
15
16#[ark_api_macros::ark_bindgen(imports = "ark-profiler-v0")]
17mod profiler {
18    use super::StreamMeta;
19
20    extern "C" {
21        /// Returns the current time in nanoseconds
22        ///
23        /// Used for high precision profiling and is only supported for profiling. May return 0 if profiling is not enabled.
24        /// Can't be used for absolute time determination, only relative difference between calls.
25        #[deprecated_infallible]
26        pub fn now_ns() -> i64;
27
28        #[deprecated(note = "Use `report_thread_stream_info` instead")] // 2021-08-23
29        #[deprecated_infallible]
30        pub fn report_thread_stream(stream: &[u8]);
31
32        /// Report Puffin profiler event stream.
33        #[deprecated_infallible]
34        pub fn report_thread_stream_info(meta: &StreamMeta, stream: &[u8]);
35
36        /// Is the module-side profiler on?
37        ///
38        /// Call `puffin::set_scopes_on(ark::profiler::is_active());`
39        /// at the top of each frame to heed this.
40        pub fn is_active() -> bool;
41    }
42}
43
44pub use profiler::*;