28package com.jogamp.opengl.test.junit.jogl.perf;
30import java.lang.reflect.InvocationTargetException;
31import java.util.concurrent.atomic.AtomicInteger;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.opengl.GLCapabilities;
35import com.jogamp.opengl.GLCapabilitiesImmutable;
36import com.jogamp.opengl.GLEventListener;
37import com.jogamp.opengl.GLProfile;
39import org.junit.BeforeClass;
40import org.junit.FixMethodOrder;
42import org.junit.runners.MethodSorters;
44import com.jogamp.common.os.Platform;
45import com.jogamp.newt.NewtFactory;
46import com.jogamp.newt.Screen;
47import com.jogamp.newt.opengl.GLWindow;
48import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
49import com.jogamp.opengl.test.junit.util.MiscUtils;
50import com.jogamp.opengl.test.junit.util.UITestCase;
55@FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 final long INIT_TIMEOUT = 10L*1000L;
64 public void test(
final GLCapabilitiesImmutable caps,
final boolean useGears,
final int width,
final int height,
final int frameCount,
final boolean reuseDevice) {
65 final int cols = (int)Math.round(Math.sqrt(frameCount));
66 final int rows = frameCount / cols;
67 final int eWidth = width/cols;
68 final int eHeight = height/rows;
71 final long[] t =
new long[10];
75 System.err.println(
"INIT START");
78 t[0] = Platform.currentTimeMillis();
80 for(
int i=0; i<frameCount; i++) {
83 frame[i].
setTitle(
"frame_"+i+
"/"+frameCount);
90 frame[i].
setSize(eWidth, eHeight);
97 initCount.incrementAndGet();
104 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {}
107 t[1] = Platform.currentTimeMillis();
108 for(
int i=0; i<frameCount; i++) {
111 t[2] = Platform.currentTimeMillis();
113 final long t0 = System.currentTimeMillis();
115 while( frameCount > initCount.get() && INIT_TIMEOUT > t1 - t0 ) {
118 System.err.println(
"Sleep initialized: "+initCount+
"/"+frameCount);
119 }
catch (
final InterruptedException e1) {
120 e1.printStackTrace();
122 t1 = System.currentTimeMillis();
124 t[3] = Platform.currentTimeMillis();
125 final double panelCountF = initCount.get();
126 System.err.printf(
"P: %d GLWindow:%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",
128 t[1]-t[0], (t[1]-t[0])/panelCountF,
129 t[3]-t[1], (t[3]-t[1])/panelCountF,
130 t[3]-t[0], (t[3]-t[0])/panelCountF);
132 System.err.println(
"INIT END: "+initCount+
"/"+frameCount);
137 Thread.sleep(duration);
138 }
catch (
final InterruptedException e1) {
139 e1.printStackTrace();
141 t[4] = Platform.currentTimeMillis();
142 for(
int i=0; i<frameCount; i++) {
146 final long ti_net = (t[4]-t[0])-duration;
147 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",
149 t[4]-t[0], (t[4]-t[0])/panelCountF,
150 ti_net, ti_net/panelCountF);
151 System.err.println(
"Total: "+(t[4]-t[0]));
159 System.err.println(
"Disabled for auto unit test until further analysis - Windows/ATI driver crash");
162 test(
new GLCapabilities(
null),
false , width, height , frameCount,
false );
166 test(
new GLCapabilities(
null),
false , width, height , frameCount,
true );
169 static long duration = 0;
170 static boolean wait =
false, mainRun =
false;
171 static int width = 800, height = 600, frameCount = 25;
173 AtomicInteger initCount =
new AtomicInteger(0);
175 public static void main(
final String[] args) {
177 boolean useGears =
false, manual=
false;
178 boolean waitMain =
false;
180 for(
int i=0; i<args.length; i++) {
181 if(args[i].equals(
"-time")) {
184 }
else if(args[i].equals(
"-width")) {
186 }
else if(args[i].equals(
"-height")) {
188 }
else if(args[i].equals(
"-count")) {
190 }
else if(args[i].equals(
"-gears")) {
192 }
else if(args[i].equals(
"-wait")) {
195 }
else if(args[i].equals(
"-waitMain")) {
198 }
else if(args[i].equals(
"-manual")) {
208 demo.
test(
null, useGears, width, height, frameCount,
false );
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void setTitle(final String title)
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static void initSingleton()
Static initialization of JOGL.
Multiple GLJPanels in a JFrame.
void test01NopGLWindowNoReuse()
void test02NopGLWindowReuse()
void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int frameCount, final boolean reuseDevice)
static void main(final String[] args)
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.