有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JOGL启动时间太长

我正试着对慢跑有一点了解,但似乎我甚至无法让这个项目正常启动

@SuppressWarnings("serial")
public class Test extends GLJPanel implements GLEventListener {
    public static final void main(final String[] args) {
        final long startTimeMillis = System.currentTimeMillis();

        final GLProfile profile = GLProfile.get(GLProfile.GL4);

        System.out.println("GLProfile#get -> " + (System.currentTimeMillis() - startTimeMillis));
        final GLCapabilities capabilities = new GLCapabilities(profile);

        final JFrame frame = new JFrame(Test.class.getName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final Test t = new Test(capabilities);
        frame.add(t);

        frame.setVisible(true);
        frame.pack();
        frame.setLocationRelativeTo(null);
    }

    public Test(final GLCapabilities capabilities) {
        super(capabilities);

        super.setPreferredSize(new Dimension(960, 640));
        super.addGLEventListener(this);
    }

    @Override
    public final void init(final GLAutoDrawable drawable) {}

    @Override
    public final void dispose(final GLAutoDrawable drawable) {}

    @Override
    public final void display(final GLAutoDrawable drawable) {}

    @Override
    public final void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width,
            final int height) {}
}

正如你所看到的,没有发生太多事情。。。代码可以工作,但启动大约需要15秒。我使用-Xprof运行它,结果是以下输出:

Flat profile of 0.01 secs (2 total ticks): TempFileCache-Reaper

  Interpreted + native   Method                        
 50.0%     1  +     0    java.io.File.list
 50.0%     0  +     1    java.io.WinNTFileSystem.delete0
100.0%     1  +     1    Total interpreted

GLProfile#get -> 13296

Flat profile of 13.44 secs (1257 total ticks): main

  Interpreted + native   Method                        
 94.2%     0  +  1162    java.lang.ProcessImpl.create
  2.3%     0  +    28    java.lang.ClassLoader$NativeLibrary.load
  0.5%     6  +     0    java.lang.ClassLoader.defineClass1
  0.2%     0  +     2    java.lang.Class.getDeclaredConstructors0
  0.2%     0  +     2    sun.java2d.d3d.D3DRenderQueue.flushBuffer
  0.2%     0  +     2    java.lang.ProcessImpl.waitForInterruptibly
  0.2%     2  +     0    sun.security.provider.SHA.implCompress
  0.1%     0  +     1    java.io.WinNTFileSystem.getBooleanAttributes
  0.1%     0  +     1    java.io.WinNTFileSystem.canonicalize0
  0.1%     0  +     1    java.net.NetworkInterface.getMacAddr0
  0.1%     0  +     1    sun.reflect.Reflection.getCallerClass
  0.1%     0  +     1    java.io.WinNTFileSystem.list
  0.1%     0  +     1    java.util.zip.ZipFile.open
  0.1%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.LoadLibraryW
  0.1%     0  +     1    java.util.zip.ZipFile.getEntry
  0.1%     0  +     1    java.security.AccessController.doPrivileged
  0.1%     1  +     0    jdk.internal.org.objectweb.asm.ByteVector.<init>
  0.1%     1  +     0    java.awt.Toolkit.initAssistiveTechnologies
  0.1%     1  +     0    sun.java2d.StateTrackableDelegate.getStateTracker
  0.1%     1  +     0    gl4.helloTriangle.Test.main
  0.1%     1  +     0    jdk.internal.org.objectweb.asm.MethodWriter.visitMaxs
  0.1%     1  +     0    java.net.URLStreamHandler.parseURL
  0.1%     1  +     0    com.jogamp.common.os.AndroidVersion.<clinit>
  0.1%     1  +     0    jogamp.nativewindow.jawt.JAWTUtil.getJAWT
  0.1%     0  +     1    java.lang.Class.getEnclosingMethod0
 99.2%    17  +  1206    Total interpreted (including elided)

         Stub + native   Method                        
  0.2%     0  +     2    java.io.WinNTFileSystem.getBooleanAttributes
  0.1%     0  +     1    java.util.zip.ZipFile.getEntrySize
  0.1%     0  +     1    java.lang.ClassLoader.findBootstrapClass
  0.1%     0  +     1    java.lang.Throwable.fillInStackTrace
  0.1%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.LoadLibraryW
  0.5%     0  +     6    Total stub

  Thread-local ticks:
  1.9%    24             Blocked (of total)
  0.3%     4             Class loader


Flat profile of 2.08 secs (197 total ticks): D3D Screen Updater

  Thread-local ticks:
100.0%   197             Blocked (of total)


Flat profile of 2.59 secs (236 total ticks): main-SharedResourceRunner

  Interpreted + native   Method                        
 20.8%     0  +     5    jogamp.nativewindow.windows.GDI.DescribePixelFormat1
 12.5%     0  +     3    jogamp.nativewindow.windows.GDIUtil.CreateDummyDispatchThread0
  4.2%     1  +     0    com.jogamp.gluegen.runtime.ProcAddressTable.isAddressField
  4.2%     1  +     0    jogamp.opengl.windows.wgl.WindowsWGLContext.getExtensionNameMap
  4.2%     0  +     1    jogamp.opengl.windows.wgl.WGL.dispatch_wglMakeCurrent0
  4.2%     1  +     0    sun.misc.URLClassPath$JarLoader$2.<init>
  4.2%     1  +     0    java.lang.Class.searchFields
  4.2%     1  +     0    sun.misc.URLClassPath$JarLoader.checkResource
  4.2%     1  +     0    jogamp.common.os.WindowsDynamicLinkerImpl.lookupSymbolLocalImpl
  4.2%     1  +     0    java.util.zip.ZipEntry.<init>
  4.2%     1  +     0    java.util.HashMap.resize
 70.8%     8  +     9    Total interpreted

     Compiled + native   Method                        
  4.2%     0  +     1    com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver.resolve
  4.2%     0  +     1    java.lang.AbstractStringBuilder.append
  4.2%     0  +     1    java.lang.reflect.Field.copy
  4.2%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.lookupSymbolLocalImpl
  4.2%     0  +     1    com.jogamp.common.os.DynamicLibraryBundle.dynamicLookupFunction
  4.2%     0  +     1    com.jogamp.gluegen.runtime.opengl.GLNameResolver.getFuncNamePermutation
 25.0%     0  +     6    Total compiled

         Stub + native   Method                        
  4.2%     0  +     1    jogamp.common.os.WindowsDynamicLinkerImpl.GetProcAddressA
  4.2%     0  +     1    Total stub

  Thread-local ticks:
 89.8%   212             Blocked (of total)


Flat profile of 0.01 secs (1 total ticks): NativeWindowFactory_ShutdownHook

  Interpreted + native   Method                        
100.0%     1  +     0    jogamp.opengl.egl.EGLDrawableFactory.shutdownImpl
100.0%     1  +     0    Total interpreted


Flat profile of 2.98 secs (267 total ticks): AWT-Windows

  Interpreted + native   Method                        
 99.3%     0  +   265    sun.awt.windows.WToolkit.eventLoop
  0.7%     0  +     2    sun.java2d.d3d.D3DGraphicsDevice.getDeviceCapsNative
100.0%     0  +   267    Total interpreted


Flat profile of 0.10 secs (10 total ticks): Thread-2

  Interpreted + native   Method                        
100.0%     0  +    10    sun.awt.windows.WToolkit.shutdown
100.0%     0  +    10    Total interpreted


Flat profile of 2.18 secs (207 total ticks): DestroyJavaVM

  Thread-local ticks:
100.0%   207             Blocked (of total)


Flat profile of 2.97 secs (267 total ticks): AWT-EventQueue-0

  Interpreted + native   Method                        
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.getCursorPos
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.findHeavyweightUnderCursor
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glLinkProgram1
  7.1%     0  +     1    sun.awt.windows.WInputMethod.enableNativeIME
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.setCursor
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glFramebufferRenderbuffer1
  7.1%     0  +     1    jogamp.opengl.windows.wgl.WGL.dispatch_wglMakeCurrent0
  7.1%     0  +     1    jogamp.opengl.gl4.GL4bcImpl.dispatch_glReadPixels1
 57.1%     0  +     8    Total interpreted

         Stub + native   Method                        
  7.1%     0  +     1    java.lang.Object.hashCode
  7.1%     0  +     1    java.lang.Thread.currentThread
  7.1%     0  +     1    java.io.WinNTFileSystem.getBooleanAttributes
  7.1%     0  +     1    java.util.zip.ZipFile.getEntry
  7.1%     0  +     1    sun.awt.windows.WGlobalCursorManager.setCursor
  7.1%     0  +     1    java.lang.ClassLoader.defineClass1
 42.9%     0  +     6    Total stub

  Thread-local ticks:
 94.8%   253             Blocked (of total)


Flat profile of 3.07 secs (277 total ticks): AWT-Shutdown

  Thread-local ticks:
100.0%   277             Blocked (of total)


Flat profile of 3.07 secs (277 total ticks): Java2D Disposer

  Thread-local ticks:
100.0%   277             Blocked (of total)


Global summary of 15.62 seconds:
100.0%  1464             Received ticks
  2.3%    33             Compilation
  0.3%     4             Class loader

(请注意,GLProfile#获得~13秒的区块!)

我已经测试了HelloTriangle,这导致了相同的结果(除了一切都运行得非常好、FPS恒定等)

我做错了什么?顺便说一下,我在Windows 10上使用Nvidia GTX

JOGL Jar runs fine on my development machine, but slowly on others? Even if they have better hardware不同的是,我对FPS/纹理没有任何问题,只是启动程序需要太长时间


共 (0) 个答案