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

How can I launch Brofiler at program startup? #23

Closed
chuckleplant opened this issue Mar 7, 2017 · 12 comments
Closed

How can I launch Brofiler at program startup? #23

chuckleplant opened this issue Mar 7, 2017 · 12 comments
Milestone

Comments

@chuckleplant
Copy link

Currently I start Brofiler while my program is running, so I can't catch the initial frames of my application. Is there a way to attach them on startup?

@JesseRMeyer
Copy link

I second this. RenderDoc allows you to launch the target .exe directly.

@Cry-Achim
Copy link

Hi chuckleplant,

I did some test with the Brofiler Test example source.
Behavior: Application will not process the update loop until you press the red "Record button" of the Brofiler application.
Note: this does not seem to be the nicest way, but it works.

bool Engine::Update()
{ BROFILER_FRAME("MainThread")

	if (!::Profiler::IsActive()) { return true; } 
	...

As further suggestion, only call this, when passing in some command line argument to your executable.

Kind Regards,
Achim

@chuckleplant
Copy link
Author

I guess that could work. Thanks!

@bombomby
Copy link
Owner

bombomby commented Mar 17, 2017

Usually I have a command line parameter for startup profiling.
Then you can have something like this in your code:

bool Engine::Update()
{
     if (startupProfiling)
     {
         Profiler::Core::Get().Activate(true);
         startupProfiling = false;
     }
     BROFILER_FRAME("MainThread")
     ...
}

Then you can connect with Brofiler later and it will cath up with early frames.

@chuckleplant
Copy link
Author

Can't I call Activate before entering the Update loop? During Setup?

@bombomby
Copy link
Owner

bombomby commented Mar 22, 2017

You need to do follow these three steps:

  1. Register main thread - just put this code in the beginning of your main() function
static ::Brofiler::ThreadScope mainThreadScope("MainThread"); 
  1. Add this code at the point where you would like to start the capture - can be the next line after 1)
if (startupProfiling)
{
     Profiler::Core::Get().Activate(true);
     Profiler::NextFrame(); //To start a new "loading" frame
}
  1. Replace PROFILER_FRAME in your main thread with this code to avoid double registration
Profiler::NextFrame(); //Update Brofiler and start the next frame
BROFILER_EVENT("Frame"); //Root event for the frame

@MatillaMartin
Copy link

MatillaMartin commented Mar 31, 2017

Profiler::Core is not accesible in the latest stable release. Is there a way to do this on v1.1.2?

@JesseRMeyer
Copy link

The reason why this is important is because time to first rendered frame is an important metric! Profiling start up code is a necessary part of this process and should be simple to do.

@mikaelwallin
Copy link

I agree with previous comment would be awesome if this could be supported.

@BrodyHiggerson
Copy link
Contributor

Profiler::Core is not accesible in the latest stable release. Is there a way to do this on v1.1.2?

Still a problem in 1.2.4 - is there some other way we should do this?

@bombomby bombomby added this to the v1.2.6 milestone Jul 28, 2019
@bombomby
Copy link
Owner

I am planning to provide a special API for this in the next release.

bombomby added a commit that referenced this issue Aug 11, 2019
- Embedding miniz library for capture compression
- Adding support for general application profiling
Optick now can operate without GUI and save captures directly to the provided path.
@bombomby
Copy link
Owner

Support for game startup performance analysis has been added in v1.2.5.
https://github.com/bombomby/optick/wiki/Optick-API#automation

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

No branches or pull requests

7 participants