diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/Chart.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/Chart.java index 9329b7e80..f1dc1577a 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/Chart.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/Chart.java @@ -486,10 +486,8 @@ public void invalidate() { } protected void runPreLayout() { - hasRunPreLayout = true; state.setDirty(dataSetState.clear()); if (state.isClean()) { - benchCssAndLayout.start(); return; } benchPreLayout.start(); @@ -529,6 +527,8 @@ protected void runPreLayout() { } benchPreLayout.stop(); + + hasRunPreLayout = true; benchCssAndLayout.start(); } @@ -573,7 +573,6 @@ protected void runPostLayout() { benchCssAndLayout.stop(); hasRunPreLayout = false; } - // nothing to do if (state.isClean() && !hasLocked) { return; diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/Axis.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/Axis.java index b41c968d4..99e533a0d 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/Axis.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/Axis.java @@ -2,6 +2,8 @@ import java.util.List; +import io.fair_acc.chartfx.profiler.Profileable; +import io.fair_acc.chartfx.profiler.Profiler; import io.fair_acc.chartfx.ui.css.LineStyle; import io.fair_acc.chartfx.ui.css.TextStyle; import io.fair_acc.dataset.events.BitState; @@ -23,7 +25,7 @@ import io.fair_acc.dataset.AxisDescription; import io.fair_acc.dataset.event.UpdateEvent; -public interface Axis extends AxisDescription { +public interface Axis extends AxisDescription, Profileable { /** * This is true when the axis determines its range from the data automatically * @@ -368,4 +370,8 @@ public interface Axis extends AxisDescription { * transformations with the modified ranges. */ default void updateCachedTransforms() {}; + + default void setProfiler(Profiler profiler) { + } + } diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/spi/AbstractAxis.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/spi/AbstractAxis.java index 08cf79311..c04938fd8 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/spi/AbstractAxis.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/spi/AbstractAxis.java @@ -406,14 +406,14 @@ private double computePrefSize(final double axisLength) { return computeMinSize(); } - benchComputePrefSize.start(); - // We can cache the existing layout if nothing has changed. final boolean isHorizontal = getSide().isHorizontal(); if (getLength() == axisLength && state.isClean(ChartBits.AxisLayout)) { return isHorizontal ? getHeight() : getWidth(); // secondary dimension } + benchComputePrefSize.start(); + // Compute the ticks with correctly placed labels to determine the // overlap. The initial estimate is usually correct, so later changes // happen very rarely, e.g., at a point where y axes labels switch to diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/DurationMeasurement.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/DurationMeasurement.java index 79c5b0294..aa4d6faf0 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/DurationMeasurement.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/DurationMeasurement.java @@ -13,18 +13,21 @@ public interface DurationMeasurement { /** * Called when an action begins. Sets the start timestamp. + * * @return start time in the used clock */ long start(); /** * Called when an action is done. Records delta from the start timestamp. + * * @return end time in the used clock */ long stop(); /** * Records the delta from now to the specified start time generated by this measurement. + * * @return end time in the used clock */ long stop(long startTime); diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/Profiler.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/Profiler.java index 30e35bb46..451af9be0 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/Profiler.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/profiler/Profiler.java @@ -4,9 +4,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Stream; /** * Creates time traces for benchmarking purposes. @@ -24,10 +22,21 @@ public interface Profiler { /** * A debug profiler that prints start/stop information and timestamps */ + /** + * @param logger log output + * @return debug printer + */ public static Profiler debugPrinter(Consumer logger) { return tag -> new MeasurementDebugPrinter(tag, logger); } + /** + * @return debug printer that prints on System.out + */ + public static Profiler debugPrinter() { + return debugPrinter(System.out::println); + } + /** * A low-overhead hdr histogram recorder that writes an aggregate histogram to disk once a second. * Check hdrhistogram.org for more information @@ -35,7 +44,7 @@ public static Profiler debugPrinter(Consumer logger) { * @param fileName the disk file * @return hdr histogram profiler */ - public static Profiler newHdrHistogramProfiler(String fileName) { + public static Profiler hdrHistogramProfiler(String fileName) { return HdrHistogramProfiler.createStarted(fileName, 1, TimeUnit.SECONDS); } @@ -45,7 +54,7 @@ public static Profiler newHdrHistogramProfiler(String fileName) { * @param title title of the chart * @return a chart profiler */ - public static Profiler newChartProfiler(String title) { + public static Profiler chartProfiler(String title) { return LiveChartProfiler.showInNewStage(title); } diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/Renderer.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/Renderer.java index f911c407b..3512083ff 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/Renderer.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/Renderer.java @@ -1,6 +1,8 @@ package io.fair_acc.chartfx.renderer; import io.fair_acc.chartfx.Chart; +import io.fair_acc.chartfx.profiler.Profileable; +import io.fair_acc.chartfx.profiler.Profiler; import io.fair_acc.chartfx.ui.css.DataSetNode; import javafx.beans.property.BooleanProperty; import javafx.collections.ObservableList; @@ -19,7 +21,7 @@ * @author braeun * @author rstein */ -public interface Renderer { +public interface Renderer extends Profileable { /** * @param dataSet the data set for which the representative icon should be generated * @param canvas the canvas in which the representative icon should be drawn @@ -131,4 +133,7 @@ default Node getNode() { return null; } + default void setProfiler(Profiler profiler) { + } + }