From b3f6b2fc9ec8aaf6aa5b4297aef1f5228eb15702 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 5 Nov 2013 16:52:29 +0100 Subject: Bug 888 / Bug 891- Enhance GLCapabilities-Query: Add raw perf. test case 'choose' only and 'full' offscreen-drawable w/ context test01ChooseOnly exposes X11/GLX perf. enhancement of 613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d: PRE CHANGE: ++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT - test01ChooseOnly INIT START #0 Run: 0, count 50/50 raw: choose 503/t 10.06/1 INIT END #0 INIT START #1 Run: 1, count 50/50 raw: choose 384/t 7.68/1 INIT END #1 INIT START #2 Run: 2, count 50/50 raw: choose 344/t 6.88/1 INIT END #2 POST CHANGE: ++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT - test01ChooseOnly INIT START #0 Run: 0, count 50/50 raw: choose 49/t 0.98/1 INIT END #0 INIT START #1 Run: 1, count 50/50 raw: choose 43/t 0.86/1 INIT END #1 INIT START #2 Run: 2, count 50/50 raw: choose 38/t 0.76/1 INIT END #2 --- .../jogl/perf/TestPerf001GLJPanelInit01AWT.java | 239 +++++++++++++++++++++ .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 239 +++++++++++++++++++++ .../junit/jogl/perf/TestPerf001RawInit00NEWT.java | 233 ++++++++++++++++++++ .../junit/jogl/perf/TestPerfGLJPanel01AWT.java | 239 --------------------- .../junit/jogl/perf/TestPerfGLJPanel02AWT.java | 239 --------------------- 5 files changed, 711 insertions(+), 478 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001RawInit00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java (limited to 'src') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java new file mode 100644 index 000000000..d47058857 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.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 TestPerf001GLJPanelInit01AWT 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 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 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= context.makeCurrent() ) { + // oops + glDrawables[i].setRealized(false); + glDrawables[i] = null; + glConti[i] = null; + continue; + } + glConti[i] = context; + context.release(); + } + t[3] = Platform.currentTimeMillis(); + // 2nd makeCurrent and release + for(int i=0; i= context.makeCurrent() ) { + // oops + glDrawables[i].setRealized(false); + glDrawables[i] = null; + glConti[i] = null; + continue; + } + context.release(); + } + t[4] = Platform.currentTimeMillis(); + + final double countF = count; + System.err.printf("Run: %d, count %d raw:%n\tglad-create\t%6d/t %6.2f/1%n"+ + "\tglad-realize\t%6d/t %6.2f/1%n"+ + "\tctx-create1\t%6d/t %6.2f/1%n"+ + "\tctx-curren2\t%6d/t %6.2f/1%n"+ + "\tglad-ctx-init\t%6d/t %6.2f/1%n", + runNum, count, + t[1]-t[0], (t[1]-t[0])/countF, // create + t[2]-t[1], (t[2]-t[1])/countF, // realize + t[3]-t[2], (t[3]-t[2])/countF, // context-create1 + t[4]-t[3], (t[4]-t[3])/countF, // context-curren2 + t[3]-t[0], (t[3]-t[0])/countF);// init total + System.err.println("INIT END #"+runNum); + if( wait && 2 == runNum ) { + UITestCase.waitForKey("Post-Init"); + } + + // destroy + for(int i=0; i 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 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