aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-05 12:58:36 +0100
committerSven Gothel <[email protected]>2013-11-05 12:58:36 +0100
commit507113e471e165d151bc152989e687439312686a (patch)
treec50b48947266798c3a50c8173b897e9f5b5a40c3
parent1f79656d49a803da74116378f84f26dc4d79db23 (diff)
Bug 888 / Bug 891- Enhance GLCapabilities-Query: Add perf. test case
Even though the test case itself cannot show the proper initialization time, it can be used w/ an attached profiler i.e. Test w/ 50 X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationFBConfig() invocations: - pre change: 1.708 ms - post change: 650 ms (613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d)
-rwxr-xr-xmake/scripts/tests-win.bat4
-rw-r--r--make/scripts/tests.sh8
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java239
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java239
5 files changed, 490 insertions, 7 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index 8de40e1f4..5aad3a54d 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -75,6 +75,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT %*
+
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %*
@@ -84,7 +87,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %*
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 63a3fa8c6..d50dd91f9 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -304,8 +304,6 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
-testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
@@ -334,6 +332,12 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $*
#
+# performance tests
+#
+testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT $*
+
+#
# tile rendring / printing w/ & w/o AWT
#
#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $*
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index fdacc5bc4..1adafaf87 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -476,13 +476,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
if( isVisible() ) {
- updater.setGraphics(g);
- backend.doPaintComponent(g);
+ updater.setGraphics(g);
+ backend.doPaintComponent(g);
}
}
}
-
/** Overridden to track when this component is added to a container.
Subclasses which override this method must call
super.addNotify() in their addNotify() method in order to
@@ -1842,7 +1841,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public boolean preGL(Graphics g) {
- GL2 gl = joglContext.getGL().getGL2();
+ final GL2 gl = joglContext.getGL().getGL2();
// Set up needed state in JOGL context from Java2D context
gl.glEnable(GL2.GL_SCISSOR_TEST);
Rectangle r = Java2D.getOGLScissorBox(g);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java
new file mode 100644
index 000000000..65b2914fb
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java
@@ -0,0 +1,239 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.perf;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Multiple GLJPanels in a JFrame's Grid
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestPerfGLJPanel01AWT extends UITestCase {
+
+ @BeforeClass
+ public static void initClass() {
+ GLProfile.initSingleton();
+ }
+
+ public void test(final boolean useGears, final int width, final int height, final int rows, final int columns,
+ final boolean useGLJPanel, final boolean useAnim) {
+ final GLAnimatorControl animator = useAnim ? new Animator() : null;
+
+ final JFrame frame;
+ final JPanel panel;
+
+ panel = new JPanel();
+ frame = new JFrame("DemoGLJPanelGridAWT");
+
+ panel.setLayout(new GridLayout(rows, columns));
+ // panel.setBounds(0, 0, width, height);
+ final int panelCount = rows*columns;
+ final Dimension eSize = new Dimension(width/columns, height/rows);
+ final long[] t = new long[10];
+ if( wait ) {
+ UITestCase.waitForKey("Pre-Init");
+ }
+ System.err.println("INIT START");
+ initCount = 0;
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ t[0] = Platform.currentTimeMillis();
+ for(int i=0; i<panelCount; i++) {
+ final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(useGears, animator, eSize) : createGLCanvas(useGears, animator, eSize);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ initCount++;
+ }
+ @Override
+ public void dispose(GLAutoDrawable drawable) {}
+ @Override
+ public void display(GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ });
+ panel.add((Component)glad);
+ }
+ t[1] = Platform.currentTimeMillis();
+ frame.getContentPane().add(panel);
+
+ // frame.validate();
+ frame.pack();
+ frame.setVisible(true);
+ t[2] = Platform.currentTimeMillis();
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ while( panelCount > initCount ) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ t[3] = Platform.currentTimeMillis();
+ final double panelCountF = panelCount;
+ System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
+ panelCount,
+ useGLJPanel?"GLJPanel":"GLCanvas",
+ t[1]-t[0], (t[1]-t[0])/panelCountF,
+ t[3]-t[1], (t[3]-t[1])/panelCountF,
+ t[3]-t[0], (t[3]-t[0])/panelCountF);
+ System.err.println("INIT END: "+initCount);
+ if( wait ) {
+ UITestCase.waitForKey("Post-Init");
+ }
+ try {
+ Thread.sleep(duration);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ t[4] = Platform.currentTimeMillis();
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.dispose();
+ } } );
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ final long ti_net = (t[4]-t[0])-duration;
+ System.err.printf("T: duration %d %d%n\ttotal-d\t%6d/t %6.2f/1%n\ttotal-i\t%6d/t %6.2f/1%n",
+ duration, t[4]-t[3],
+ t[4]-t[0], (t[4]-t[0])/panelCountF,
+ ti_net, ti_net/panelCountF);
+ System.err.println("Total: "+(t[4]-t[0]));
+ }
+
+ private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) {
+ GLCanvas canvas = new GLCanvas();
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ canvas.addGLEventListener(new GearsES2());
+ }
+ if( null != anim ) {
+ anim.add(canvas);
+ }
+ return canvas;
+ }
+ private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) {
+ GLJPanel canvas = new GLJPanel();
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ canvas.addGLEventListener(new GearsES2());
+ }
+ if( null != anim ) {
+ anim.add(canvas);
+ }
+ return canvas;
+ }
+
+ @Test
+ public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException {
+ final int width = 800, height = 600, rows = 5, cols = 5;
+ test(false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ }
+
+ @Test
+ public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException {
+ final int width = 800, height = 600, rows = 5, cols = 5;
+ test(false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/);
+ }
+
+ static long duration = 2000; // ms
+ static boolean wait = false;
+
+ volatile int initCount = 0;
+
+ public static void main(String[] args) {
+ int width = 800, height = 600, rows = 5, cols = 5;
+ boolean useGLJPanel = true, useGears = false, manual=false;
+
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-width")) {
+ width = MiscUtils.atoi(args[++i], width);
+ } else if(args[i].equals("-height")) {
+ height = MiscUtils.atoi(args[++i], height);
+ } else if(args[i].equals("-rows")) {
+ rows = MiscUtils.atoi(args[++i], rows);
+ } else if(args[i].equals("-cols")) {
+ cols = MiscUtils.atoi(args[++i], cols);
+ } else if(args[i].equals("-glcanvas")) {
+ useGLJPanel = false;
+ } else if(args[i].equals("-gears")) {
+ useGears = true;
+ } else if(args[i].equals("-wait")) {
+ wait = true;
+ manual = true;
+ } else if(args[i].equals("-manual")) {
+ manual = true;
+ }
+ }
+ if( manual ) {
+ GLProfile.initSingleton();
+ TestPerfGLJPanel01AWT demo = new TestPerfGLJPanel01AWT();
+ demo.test(useGears, width, height, rows, cols, useGLJPanel, false /*useAnim*/);
+ } else {
+ org.junit.runner.JUnitCore.main(TestPerfGLJPanel01AWT.class.getName());
+ }
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java
new file mode 100644
index 000000000..f1c56309b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java
@@ -0,0 +1,239 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.perf;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Multiple GLJPanels in a JFrame
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestPerfGLJPanel02AWT extends UITestCase {
+
+ @BeforeClass
+ public static void initClass() {
+ GLProfile.initSingleton();
+ }
+
+ public void test(final boolean useGears, final int width, final int height, final int frameCount,
+ final boolean useGLJPanel, final boolean useAnim) {
+ final GLAnimatorControl animator = useAnim ? new Animator() : null;
+
+ final JFrame[] frame = new JFrame[frameCount];
+ final long[] t = new long[10];
+ if( wait ) {
+ UITestCase.waitForKey("Pre-Init");
+ }
+ System.err.println("INIT START");
+ initCount = 0;
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ t[0] = Platform.currentTimeMillis();
+ for(int i=0; i<frameCount; i++) {
+ frame[i] = new JFrame("frame_"+i+"/"+frameCount);
+ final JPanel panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ // panel.setBounds(0, 0, width, height);
+ final Dimension eSize = new Dimension(width, height);
+ final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(useGears, animator, eSize) : createGLCanvas(useGears, animator, eSize);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ initCount++;
+ }
+ @Override
+ public void dispose(GLAutoDrawable drawable) {}
+ @Override
+ public void display(GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ });
+ panel.add((Component)glad);
+ frame[i].getContentPane().add(panel);
+
+ // frame.validate();
+ frame[i].pack();
+ }
+ t[1] = Platform.currentTimeMillis();
+ for(int i=0; i<frameCount; i++) {
+ frame[i].setVisible(true);
+ }
+ t[2] = Platform.currentTimeMillis();
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ while( frameCount > initCount ) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ t[3] = Platform.currentTimeMillis();
+ final double panelCountF = frameCount;
+ System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
+ frameCount,
+ useGLJPanel?"GLJPanel":"GLCanvas",
+ t[1]-t[0], (t[1]-t[0])/panelCountF,
+ t[3]-t[1], (t[3]-t[1])/panelCountF,
+ t[3]-t[0], (t[3]-t[0])/panelCountF);
+
+ System.err.println("INIT END: "+initCount);
+ if( wait ) {
+ UITestCase.waitForKey("Post-Init");
+ }
+ try {
+ Thread.sleep(duration);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ t[4] = Platform.currentTimeMillis();
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ for(int i=0; i<frameCount; i++) {
+ frame[i].dispose();
+ }
+ } } );
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ final long ti_net = (t[4]-t[0])-duration;
+ System.err.printf("T: duration %d %d%n\ttotal-d\t%6d/t %6.2f/1%n\ttotal-i\t%6d/t %6.2f/1%n",
+ duration, t[4]-t[3],
+ t[4]-t[0], (t[4]-t[0])/panelCountF,
+ ti_net, ti_net/panelCountF);
+ System.err.println("Total: "+(t[4]-t[0]));
+ }
+
+ private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) {
+ GLCanvas canvas = new GLCanvas();
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ canvas.addGLEventListener(new GearsES2());
+ }
+ if( null != anim ) {
+ anim.add(canvas);
+ }
+ return canvas;
+ }
+ private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) {
+ GLJPanel canvas = new GLJPanel();
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ canvas.addGLEventListener(new GearsES2());
+ }
+ if( null != anim ) {
+ anim.add(canvas);
+ }
+ return canvas;
+ }
+
+ @Test
+ public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException {
+ final int width = 800, height = 600, frameCount = 25;
+ test(false /*useGears*/, width, height, frameCount , true /* useGLJPanel */, false /*useAnim*/);
+ }
+
+ @Test
+ public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException {
+ final int width = 800, height = 600, frameCount = 25;
+ test(false /*useGears*/, width, height, frameCount , false /* useGLJPanel */, false /*useAnim*/);
+ }
+
+ static long duration = 2000; // ms
+ static boolean wait = false;
+
+ volatile int initCount = 0;
+
+ public static void main(String[] args) {
+ int width = 800, height = 600, frameCount = 25;
+ boolean useGLJPanel = true, useGears = false, manual=false;
+
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-width")) {
+ width = MiscUtils.atoi(args[++i], width);
+ } else if(args[i].equals("-height")) {
+ height = MiscUtils.atoi(args[++i], height);
+ } else if(args[i].equals("-count")) {
+ frameCount = MiscUtils.atoi(args[++i], frameCount);
+ } else if(args[i].equals("-glcanvas")) {
+ useGLJPanel = false;
+ } else if(args[i].equals("-gears")) {
+ useGears = true;
+ } else if(args[i].equals("-wait")) {
+ wait = true;
+ manual = true;
+ } else if(args[i].equals("-manual")) {
+ manual = true;
+ }
+ }
+ if( manual ) {
+ GLProfile.initSingleton();
+ TestPerfGLJPanel02AWT demo = new TestPerfGLJPanel02AWT();
+ demo.test(useGears, width, height, frameCount, useGLJPanel, false /*useAnim*/);
+ } else {
+ org.junit.runner.JUnitCore.main(TestPerfGLJPanel02AWT.class.getName());
+ }
+ }
+
+}