darklaf icon indicating copy to clipboard operation
darklaf copied to clipboard

Dynamic performance of darklaf

Open kirill-grouchnikov opened this issue 4 years ago • 3 comments

I use Lightbeam in Substance to track performance regressions and measure potential performance improvements. Every once in a while I run it on a selection of core and third-party look-and-feels to see how Substance stacks up.

I just ran the performance suite on the latest stable release of darklaf, and I'm seeing darklaf numbers that are like this:

image

As you can see, other look-and-feels are more or less on the same level. There are a couple that use drop shadows on the menus, and that adds extra cost. There are also two LAFs that are base on Synth (Nimbus and Synthetica) that seem to have performance issues with sliders. But otherwise it's pretty close. Except for darklaf. The whole Lightbeam suite stutters and lags to refresh the UI, and the numbers seem to back that up.

I downloaded the latest stable darklaf binaries from https://search.maven.org/search?q=darklaf and svgsalamander from https://search.maven.org/search?q=svgsalamander

To build Lightbeam locally, download the latest zip from Radiance's Github, and run gradlew, gradlew copyJars, gradlew getAllDependencies.

Then, to run Lightbeam with darklaf:

export JAVA_HOME=`/usr/libexec/java_home -v 9`
alias JAVA="java"

RADIANCE_VERSION=3.0-SNAPSHOT
CLASSPATH=../../drop/$RADIANCE_VERSION/tools/radiance-lightbeam-$RADIANCE_VERSION.jar:../../build/libs-tools/jgoodies-forms-1.9.0.jar:../../build/libs-tools/jgoodies-common-1.8.1.jar
DARKLAF_CLASSPATH=../../../thirdparty/darklaf/*

java -Dswing.defaultlaf=com.github.weisj.darklaf.DarkLaf -cp $CLASSPATH:$DARKLAF_CLASSPATH org.pushingpixels.lightbeam.DynamicPerformanceSuite 10

The location of lightbeam and jgoodies jars matches where the Radiance build script will put them. The location of darklaf jars can be tweaked to match what you have on your system.

Let me know if you have questions on how Lightbeam works beyond the documentation at https://github.com/kirill-grouchnikov/radiance/blob/master/docs/tools/lightbeam/lightbeam.md

kirill-grouchnikov avatar May 04 '20 04:05 kirill-grouchnikov

https://github.com/kirill-grouchnikov/radiance/blob/master/tools/lightbeam/src/main/java/org/pushingpixels/lightbeam/panels/ButtonsPanel.java#L441 is the code for the first scenario - dynamically change JButton texts and measuring how much it takes to complete that and repaint the button panel.

kirill-grouchnikov avatar May 04 '20 04:05 kirill-grouchnikov

Thank you for the insight. I’ll have a look at what causes the performance issues.

weisJ avatar May 04 '20 06:05 weisJ

After doing some analysis I could mitigate some of the performance issues. Most time was wasted painting the svg icons and doing heavy Area calculations during painting. After adding image caching to the DarkSVGIcon implementation and removing unnecessary usage of Area I could improve the performance to where it is at ~2700 compared to the system laf at ~2100.

Still the first few iterations are a lot worst that the system laf (in the order of x2 or x3) because the icons are being loaded lazily.

Still some work to be done but a good first start.

weisJ avatar May 25 '20 16:05 weisJ