Clojure swing应用程序启动时间
我刚开始使用clojure和跷跷板制作GUI应用程序。它只创建一个JFrame和几个组件。这是密码。主函数除了调用Clojure swing应用程序启动时间,swing,clojure,jvm,leiningen,seesaw,Swing,Clojure,Jvm,Leiningen,Seesaw,我刚开始使用clojure和跷跷板制作GUI应用程序。它只创建一个JFrame和几个组件。这是密码。主函数除了调用start gui并在返回后立即退出外,什么也不做 (ns pause.gui (:use seesaw.core)) (native!) ; (javax.swing.UIManager/setLookAndFeel ; "org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel") (def m
start gui
并在返回后立即退出外,什么也不做
(ns pause.gui
(:use seesaw.core))
(native!)
; (javax.swing.UIManager/setLookAndFeel
; "org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel")
(def main-window
(frame :title "Pause"
:on-close :exit))
(def sidebar (listbox :model []))
(def main-area (text :multi-line? true
:font "MONOSPACED-PLAIN-14"
:text "test"))
(def main-split
(left-right-split (scrollable sidebar)
(scrollable main-area)
:divider-location 1/5))
(defn setup-main-window
"Fills the main window with its content"
[main-window]
(config! main-window
:content main-split)
main-window)
(defn start-gui
"Create the main window"
[]
(-> main-window
setup-main-window
pack!
show!))
我使用
leinuberjar
编译了这篇文章,并用timejava-jar
计时。它报告了14.5秒。我做错什么了吗?我可以用3秒钟启动,但这是完全不能接受的。可悲的是,Clojure还有相当多的启动时间。这主要是因为Clojure在所有必需的名称空间中加载时,会发生大量的编译/代码加载
对于我编写的基于Swing的GUI应用程序,我经常用Java编写
main
入口点,这样您就可以向用户快速显示初始GUI或启动屏幕,而其余的应用程序/Clojure代码则在后台加载。在编译步骤中,它不会将所有Clojure代码编译为字节码(即在制作jar时)?有没有办法强制它?在ns
子句中添加:gen class
会有帮助吗?可能会有帮助。但是还有很多其他代码(例如库)不是用gen class.YMMV预编译的。