1#[cfg(feature = "macros")]
2pub use timetrace_macros::{profile_function, profile_session, profile_session_limited};
3
4mod backends;
5pub mod profile_result;
6pub mod profiler;
7pub mod profiler_timer;
8pub use profiler_timer::ProfilerTimer;
9
10pub use backends::base::TracingBackend;
11
12#[cfg(all(feature = "tracy", feature = "json"))]
13compile_error!("features 'tracy' and 'json' are mutually exclusive");
14
15#[macro_export]
106macro_rules! profile_begin_session {
107 ($name:expr, $filepath:expr) => {
108 use $crate::TracingBackend;
109 $crate::profiler::Profiler::get()
110 .lock()
111 .begin_session($name, $filepath);
112 };
113}
114
115#[macro_export]
116macro_rules! profile_begin_session_limited {
117 ($name:expr, $path:expr, $frames:expr, $ms:expr) => {
118 use $crate::TracingBackend;
119 $crate::profiler::Profiler::get()
120 .lock()
121 .begin_session_limited($name, $path, $frames, $ms);
122 };
123}
124
125#[macro_export]
126macro_rules! profile_end_session {
127 () => {
128 use $crate::TracingBackend;
129 $crate::profiler::Profiler::get()
130 .lock()
131 .end_session()
132 .unwrap();
133 };
134}
135
136#[macro_export]
137macro_rules! profile_scope {
138 ($name:expr) => {
139 use $crate::TracingBackend;
140 let _timer = $crate::profiler_timer::ProfilerTimer::new($name);
141 };
142}
143
144#[macro_export]
145macro_rules! profile_function_scope {
146 () => {
147 use $crate::TracingBackend;
148 let _timer = $crate::profiler_timer::ProfilerTimer::new(module_path!());
149 };
150}
151
152#[macro_export]
153macro_rules! profile_new_frame {
154 () => {
155 use $crate::TracingBackend;
156 $crate::profiler::Profiler::get().lock().new_frame();
157 };
158}
159#[macro_export]
160macro_rules! profile_update {
161 ($name:expr, $value:expr) => {
162 use $crate::TracingBackend;
163 profile_new_frame!();
164 };
165}