Added an easy way to add sub steps to the profiler (#1067)

* Added an easy way to add sub steps to the profiler and enhanced the App State Manager to profile the update method of each app state

* Added the profiler step to the android profiler

* Fixed missing profiler extensions
This commit is contained in:
Greg Hoffman 2019-04-22 01:41:40 -07:00 committed by Stephen Gold
parent ffa1df2aff
commit 0bc060d474
6 changed files with 34 additions and 0 deletions

View File

@ -135,6 +135,11 @@ public class DefaultAndroidProfiler implements AppProfiler {
}
}
@Override
public void appSubStep(String... additionalInfo) {
}
public void vpStep(VpStep vpStep, ViewPort vp, RenderQueue.Bucket bucket) {
if (androidApiLevel >= 18) {
switch (vpStep) {

View File

@ -187,6 +187,10 @@ public class BasicProfiler implements AppProfiler {
}
}
@Override
public void appSubStep(String... additionalInfo) {
}
@Override
public void vpStep( VpStep step, ViewPort vp, Bucket bucket ) {
}

View File

@ -88,6 +88,17 @@ public class DetailedProfiler implements AppProfiler {
}
}
@Override
public void appSubStep(String... additionalInfo) {
if (data != null) {
String pathStep = getPath("", additionalInfo);
path.setLength(0);
path.append(curAppPath).append(pathStep);
addStep(path.toString(), System.nanoTime());
}
}
private void closeFrame() {
//close frame
if (data != null) {

View File

@ -32,6 +32,7 @@
package com.jme3.app.state;
import com.jme3.app.Application;
import com.jme3.profile.AppProfiler;
import com.jme3.renderer.RenderManager;
import com.jme3.util.SafeArrayList;
import java.util.Arrays;
@ -300,6 +301,9 @@ public class AppStateManager {
AppState[] array = getStates();
for (AppState state : array){
if (state.isEnabled()) {
if (app.getAppProfiler() != null) {
app.getAppProfiler().appSubStep(state.getClass().getSimpleName());
}
state.update(tpf);
}
}

View File

@ -51,6 +51,11 @@ public interface AppProfiler {
*/
public void appStep(AppStep step);
/**
* Called as a substep of the previous AppStep
*/
public void appSubStep(String... additionalInfo);
/**
* Called at the beginning of the specified VpStep during
* the rendering of the specified ViewPort. For bucket-specific

View File

@ -90,6 +90,11 @@ public class TestShaderNodesStress extends SimpleApplication {
}
@Override
public void appSubStep(String... additionalInfo) {
}
@Override
public void vpStep(VpStep step, ViewPort vp, RenderQueue.Bucket bucket) {