aclysma / profiling

Provides a very thin abstraction over instrumented profiling crates like puffin, optick, tracy, and superluminal-perf.
Apache License 2.0
320 stars 39 forks source link

Allow manual management of scope guards #3

Closed Imberflur closed 3 years ago

Imberflur commented 3 years ago

In some cases it's useful to be able to manually drop the scope guards. For instance, if you want to profile a portion of a function without adding additional indentation. Another case is having scopes that cover portions of time where control is passed back to winit.

aclysma commented 3 years ago

I think this is a helpful thing to be able to do if we can find a simple solution that supports all backends and potentially multiple guard objects being involved. I want to stay sensitive to the fact that some people aren't going to want to take this crate as a dependency unless it stays small and simple, and I think some of the value this crate could provide is that it is small enough that some upstream crates might be more willing to add profiling instrumentation that we as downstream users can benefit from. Also, since end-users can interface directly with their profiling crate of choice I think it takes a little pressure off this library needing to support every case. Again though, if we find a clean and simple way to do it that supports every backend, I'm in favor of adding the feature. :)

Imberflur commented 3 years ago

That makes sense to me :+1:. This could always be in a separate crate for those that want more precise control in exchange for more complexity. I might try to whip a PR to see what it would look like, but I wouldn't have any issues if it ultimately is left out.

aclysma commented 3 years ago

Will close for now, but happy to look if you have more ideas on how to do it! :)