Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ::{{closure}} in more cases from function names #230

Merged
merged 6 commits into from
Aug 6, 2024

Conversation

Hoodad
Copy link
Contributor

@Hoodad Hoodad commented Aug 5, 2024

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

This removes all ::{{closure}} from the suffix of a function name when cleaning the name. Previously this was limited to 2.

This is noticeable with the changes made in #225 where the main function being labeled as main::{{closure}}

Before

image

After

Screenshot 2024-08-05 131903

@Hoodad Hoodad changed the title Hoodad/fix cleaning of functions Remove ::{{closure}} in more cases from function names Aug 5, 2024
Copy link
Member

@TimonPost TimonPost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this always remove the closure tag? I wonder if we may wanna keep some way of referring to if there is a closure or not. Perhaps this could be a metadata information when hovering over the frame.

@Hoodad
Copy link
Contributor Author

Hoodad commented Aug 5, 2024

I haven't tested how this looks with more closure examples. But can try it out more.

Regarding the function to have something come up as a closure, personally I would rather see a name then a generic closure tag, though I cannot say that I'm a heavy user of profiling scopes 🙈

This PR was more a fix for the odd name in the examples then any new functionality.

@Hoodad
Copy link
Contributor Author

Hoodad commented Aug 6, 2024

I did sanity check the code and it does behave as advertised, removing all mentions of ::{{closure}}.

If you then profile a closure and use puffin::profile_function() it will be labelled the same as the function where the closure is being called. If a name is required I would suggest opting for profile::profile_scope() instead as then you can give it a name.

@TimonPost
Copy link
Member

TimonPost commented Aug 6, 2024

Makes sense to me for ppl to use scopes in this case 👍

@emilk
Copy link
Collaborator

emilk commented Aug 6, 2024

We may wanna add that to the docstring of profile_function, that it is only meant for the outermost scope of a fn function, and NOT for lambdas.

@Hoodad
Copy link
Contributor Author

Hoodad commented Aug 6, 2024

Yeah make sense, I did update the documentation now.

Though I realize now with the change in documentation the eframe example does not adhere to this standard as it uses the profile_function in the eframe::run_simple_native. That said I think its fine as the output will be eframe::main which is expected. Just a tiny bit inconsistent with the documentation 🙈

@Hoodad Hoodad merged commit 3e569df into main Aug 6, 2024
7 checks passed
@Hoodad Hoodad deleted the hoodad/fix-cleaning-of-functions branch August 6, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants