-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
207 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ target | |
**/*.rs.bk | ||
Cargo.lock | ||
*.tar.gz | ||
flamegraph.svg | ||
perf.data* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[derive(Clone, Copy, Debug, Default)] | ||
pub struct Macrostep { | ||
pub tasks: usize, | ||
pub ticks: u64, | ||
} | ||
|
||
impl Macrostep { | ||
pub fn metrics(&self) { | ||
measure!("tasks", self.tasks as u32); | ||
measure!( | ||
"advance", | ||
crate::time::resolution::ticks_to_duration(self.ticks) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
extern crate alloc; | ||
|
||
#[macro_use] | ||
mod tracing; | ||
#[macro_use] | ||
pub mod metrics; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,55 @@ | ||
#[doc(hidden)] | ||
#[cfg(feature = "metrics")] | ||
pub mod macro_support { | ||
pub use ::metrics::*; | ||
pub use ::tracing::trace; | ||
} | ||
|
||
#[macro_export] | ||
#[cfg(feature = "metrics")] | ||
macro_rules! measure { | ||
($name:literal, $value:expr $(, $key:literal = $v:expr)* $(,)?) => { | ||
$crate::metrics::macro_support::trace!(measure = %$name, value = ?$value $(, $key = %$v)*); | ||
$crate::tracing::trace!(measure = %$name, value = ?$value $(, $key = %$v)*); | ||
$crate::metrics::macro_support::histogram!($name $(, $key => $v)*).record($value); | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
#[cfg(not(feature = "metrics"))] | ||
macro_rules! measure { | ||
($name:literal, $value:expr $(, $key:literal = $v:expr)* $(,)?) => { | ||
let _ = $name; | ||
let _ = $value; | ||
$( | ||
let _ = $key; | ||
let _ = $v; | ||
)* | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
#[cfg(feature = "metrics")] | ||
macro_rules! count { | ||
($name:literal $(, $key:literal = $v:expr)* $(,)?) => { | ||
$crate::count!($name, 1 $(, $key = $v)*); | ||
}; | ||
($name:literal, $value:expr $(, $key:literal = $v:expr)* $(,)?) => { | ||
$crate::metrics::macro_support::trace!(count = %$name, value = %$value $(, $key = %$v)*); | ||
$crate::tracing::trace!(count = %$name, value = %$value $(, $key = %$v)*); | ||
$crate::metrics::macro_support::counter!($name $(, $key => $v)*).increment($value); | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
#[cfg(not(feature = "metrics"))] | ||
macro_rules! count { | ||
($name:literal $(, $key:literal = $v:expr)* $(,)?) => { | ||
$crate::count!($name, 1 $(, $key = $v)*); | ||
}; | ||
($name:literal, $value:expr $(, $key:literal = $v:expr)* $(,)?) => { | ||
let _ = $name; | ||
let _ = $value; | ||
$( | ||
let _ = $key; | ||
let _ = $v; | ||
)* | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.