Przeglądaj źródła

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
Greg Hoffman 6 lat temu
rodzic
commit
0bc060d474

+ 5 - 0
jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java

@@ -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) {

+ 4 - 0
jme3-core/src/main/java/com/jme3/app/BasicProfiler.java

@@ -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 ) {
     }

+ 11 - 0
jme3-core/src/main/java/com/jme3/app/DetailedProfiler.java

@@ -87,6 +87,17 @@ public class DetailedProfiler implements AppProfiler {
             closeFrame();
         }
     }
+    
+    
+    @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

+ 4 - 0
jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java

@@ -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);
             }
         }

+ 5 - 0
jme3-core/src/main/java/com/jme3/profile/AppProfiler.java

@@ -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

+ 5 - 0
jme3-examples/src/main/java/jme3test/stress/TestShaderNodesStress.java

@@ -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) {