1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Add more puffin profile scopes to eframe (#3330)

* Add puffin profile scopes to the startup and running of eframe

* puffin_profiler example: start puffin right away

* cargo format let-else statements

* More profile scopes

* Add some `#[inline]`

* Standardize puffin profile scope definitions

* standardize again

* Silence warning when puffin is disabled
This commit is contained in:
Emil Ernerfeldt
2023-09-13 09:00:38 +02:00
committed by GitHub
parent 2bc6814acc
commit fc3bddd0cf
17 changed files with 414 additions and 255 deletions

View File

@@ -31,6 +31,7 @@ pub struct FileStorage {
impl Drop for FileStorage {
fn drop(&mut self) {
if let Some(join_handle) = self.last_save_join_handle.take() {
crate::profile_scope!("wait_for_save");
join_handle.join().ok();
}
}
@@ -39,6 +40,7 @@ impl Drop for FileStorage {
impl FileStorage {
/// Store the state in this .ron file.
fn from_ron_filepath(ron_filepath: impl Into<PathBuf>) -> Self {
crate::profile_function!();
let ron_filepath: PathBuf = ron_filepath.into();
log::debug!("Loading app state from {:?}…", ron_filepath);
Self {
@@ -51,6 +53,7 @@ impl FileStorage {
/// Find a good place to put the files that the OS likes.
pub fn from_app_id(app_id: &str) -> Option<Self> {
crate::profile_function!(app_id);
if let Some(data_dir) = storage_dir(app_id) {
if let Err(err) = std::fs::create_dir_all(&data_dir) {
log::warn!(
@@ -83,6 +86,7 @@ impl crate::Storage for FileStorage {
fn flush(&mut self) {
if self.dirty {
crate::profile_function!();
self.dirty = false;
let file_path = self.ron_filepath.clone();
@@ -142,6 +146,7 @@ fn read_ron<T>(ron_path: impl AsRef<Path>) -> Option<T>
where
T: serde::de::DeserializeOwned,
{
crate::profile_function!();
match std::fs::File::open(ron_path) {
Ok(file) => {
let reader = std::io::BufReader::new(file);