Permlink Replies: 7 - Pages: 1 - Last Post: 03-Dec-2018 18:50 Last Post By: davidekholm Threads: [ Previous | Next ]
davidekholm

Posts: 3,859
Registered: 18-Oct-2002
On Groovy performance
Posted: 01-Dec-2018 11:35
  Click to reply to this thread Reply
It was saddening to see the slow textual parsing of Groovy when I had adjusted the onload script for Minimal to Groovy (By adding {} in two locations). However, the Groovy team reports that it was due to the "complexity" of the script, not the length. I'm still investigating what they mean by that. Here's a 3 times larger script for Base that loads in a fraction of that time. Can you figure out what makes Minimal's script so slow?

I've attached "Groovy" versions of both Minimal and Base for comparison.
I've added skin loading timings to be printed to the system console in jAlbum 17.1 so it's easier to make measurements. It's worth noticing that skin loading picks up speed in Groovy the more times you load the same script.
jGromit

Posts: 8,630
Registered: 31-Jan-2006
Re: On Groovy performance
Posted: 01-Dec-2018 12:59   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
If I comment out these three lines in MinimalGroovy, it loads in one-tenth the time:
b = new JButton("Snygg")
add b
b.addActionListener { b.text="Det funkade" }
davidekholm

Posts: 3,859
Registered: 18-Oct-2002
Re: On Groovy performance
Posted: 01-Dec-2018 20:22   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
Awesome that you discovered that. Not even the Groovy people figured that out. It was actually the relaxed add b statement that was the culprit. Change to add(b) and it's 8 times faster :-)
jGromit

Posts: 8,630
Registered: 31-Jan-2006
Re: On Groovy performance
Posted: 01-Dec-2018 21:21   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
It gets even faster if you put semicolons where they belong:
b = new JButton("Snygg");
add(b);
Before changes, 2.907s. After changes, 0.16s. That's 18 times faster.
davidekholm

Posts: 3,859
Registered: 18-Oct-2002
Re: On Groovy performance
Posted: 01-Dec-2018 23:21   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
It gets even faster if you put semicolons where they belong:
b = new JButton("Snygg");
add(b);
Before changes, 2.907s. After changes, 0.16s. That's 18 times faster.

That's rather an effect of some caching the compiler is doing. Try removing the semicolons again and save and reload. Anyway, I'll stick to semicolons at it's more Java-like

RobM

Posts: 3,355
Registered: 4-Aug-2006
Re: On Groovy performance
Posted: 01-Dec-2018 23:35   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
I converted one of my old skins to Groovy, 3 button groups, 2 text boxes and 5 checkboxes for settings and an about tab.
Condition         Groovy Time    Bsh Time
First load          2.01s          0.3s
Reload              0.20s          0.15s
Empty project       0.15s          0.06
RobM

Posts: 3,355
Registered: 4-Aug-2006
Re: On Groovy performance
Posted: 01-Dec-2018 23:42   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
For comparison, timings for minimalGroovy with above modifications:
First load 3.065s, Reload 0.26s, Empty project 0.26s
davidekholm

Posts: 3,859
Registered: 18-Oct-2002
Re: On Groovy performance
Posted: 03-Dec-2018 18:50   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Yes, the 1:st load is still significantly slower. I believe they (the Groovy people) will have a better initial performance in the next round.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums