screeps-profiler icon indicating copy to clipboard operation
screeps-profiler copied to clipboard

[Feature] Profile Section

Open RiftLurker opened this issue 7 years ago • 1 comments

The profiler should be able to profile a certain section of code.

Currently you would have to wrap it into a function and call that:

// some code
profiler.registerFN(() => {
	// some complex code that should get profiled
}, 'mySection') ();
// some code

Because you can't just drop-in section profiling I suggest one of the following alternatives:

// some code
const end = profiler.start('mySection');
// some complex code that should get profiled
end(); // maybe even return profiling data for this section
// some code

or

// some code
profiler.start('mySection');
// some complex code that should get profiled
profiler.end('mySection'); // maybe even return profiling data for this section
// some code

Once this is implemented it should probably also be used internally to wrap functions.

RiftLurker avatar May 17 '17 08:05 RiftLurker

This might have some value in terms of checking specific areas of code, but I think that profiling functions is more important. It's more likely that you have an expensive function that is called in several different areas of your app.

I'm not opposed to adding this additional api, but I'd like to feel out how it would work with wrap and registerFN, also what would this look like in the reports?

gdborton avatar May 18 '17 20:05 gdborton