This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 47cde567fbbbf4aaf7c4106e2afa711a0646b7d4 Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed May 18 18:04:03 2022 +0200 Rename logging level relative to slow operations. --- .../java/org/apache/sis/gui/dataset/LogViewer.java | 2 +- .../apache/sis/util/logging/MonolineFormatter.java | 2 +- .../apache/sis/util/logging/PerformanceLevel.java | 30 ++++++++++------- .../org/apache/sis/util/resources/Vocabulary.java | 8 ++--- .../sis/util/resources/Vocabulary.properties | 2 +- .../sis/util/resources/Vocabulary_fr.properties | 2 +- .../sis/util/logging/PerformanceLevelTest.java | 38 +++++++++++----------- .../sis/storage/AbstractGridCoverageResource.java | 2 +- 8 files changed, 47 insertions(+), 39 deletions(-) diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/LogViewer.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/LogViewer.java index b0fcaf7db6..f2416fd28d 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/LogViewer.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/LogViewer.java @@ -286,7 +286,7 @@ public class LogViewer extends Widget { final ChoiceBox<Level> levels = new ChoiceBox<>(); levelLabel.setLabelFor(levels); levels.getItems().setAll(Level.SEVERE, Level.WARNING, Level.INFO, Level.CONFIG, - PerformanceLevel.SLOW, Level.FINE, Level.FINER, Level.ALL); + PerformanceLevel.SLOWNESS, Level.FINE, Level.FINER, Level.ALL); levels.setConverter(Converter.INSTANCE); levels.getSelectionModel().selectedItemProperty().addListener((p,o,n) -> setFilter(n, filteredLogger)); levels.getSelectionModel().select(filteredLevel); diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java index 4966b0188d..8acd4f61b2 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java @@ -597,7 +597,7 @@ loop: for (int i=0; ; i++) { colors.put(Level.INFO, X364.BACKGROUND_GREEN); colors.put(Level.WARNING, X364.BACKGROUND_YELLOW); colors.put(Level.SEVERE, X364.BACKGROUND_RED); - colors.put(PerformanceLevel.SLOW, X364.BACKGROUND_CYAN); + colors.put(PerformanceLevel.SLOWNESS, X364.BACKGROUND_CYAN); } /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java index 6c0a5f39d6..71d6bad11c 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java @@ -28,7 +28,7 @@ import org.apache.sis.util.resources.Vocabulary; * Logging levels for data processing with execution time measurements. * Those levels are used for events that would normally be logged at {@link Level#FINE}, * but with the possibility to use a slightly higher level if execution time was long. - * Different logging levels - {@link #SLOW} and {@link #SLOWER} - are provided for logging + * Different logging levels - {@link #SLOWNESS} and {@link #SLOWER} - are provided for logging * only the events taking more time than some thresholds. For example the console could log * only the slowest events, while a file could log all events considered slow. * @@ -51,7 +51,7 @@ import org.apache.sis.util.resources.Vocabulary; * </ul> * * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.3 * @since 0.3 * @module */ @@ -64,18 +64,26 @@ public final class PerformanceLevel extends Level { /** * The level for logging relatively slow events. By default, only events having an execution * time equals or greater than 1 second are logged at this level. However this threshold can - * be changed by a call to <code>SLOW.{@linkplain #setMinDuration(long, TimeUnit)}</code>. + * be changed by a call to <code>SLOWNESS.{@linkplain #setMinDuration(long, TimeUnit)}</code>. + * + * @since 1.3 */ - public static final PerformanceLevel SLOW = new PerformanceLevel("SLOW", Vocabulary.Keys.Slow, 620, 1000_000_000L); + public static final PerformanceLevel SLOWNESS = new PerformanceLevel("SLOWNESS", Vocabulary.Keys.Slowness, 620, 1000_000_000L); /** - * The level for logging only events slower than the ones logged at the {@link #SLOW} level. + * The level for logging only events slower than the ones logged at the {@link #SLOWNESS} level. * By default, only events having an execution time equals or greater than 10 seconds are * logged at this level. However this threshold can be changed by a call to * <code>SLOWER.{@linkplain #setMinDuration(long, TimeUnit)}</code>. */ public static final PerformanceLevel SLOWER = new PerformanceLevel("SLOWER", Vocabulary.Keys.Slower, 630, 10_000_000_000L); + /** + * @deprecated Renamed {@link #SLOWNESS}. + */ + @Deprecated + public static final PerformanceLevel SLOW = SLOWNESS; + /** * The minimal duration (in nanoseconds) for logging the record. */ @@ -101,7 +109,7 @@ public final class PerformanceLevel extends Level { /** * Returns the level to use for logging an event of the given duration. - * The method may return {@link Level#FINE}, {@link #SLOW} or {@link #SLOWER} + * The method may return {@link Level#FINE}, {@link #SLOWNESS} or {@link #SLOWER} * depending on the duration. * * @param duration the event duration. @@ -110,10 +118,10 @@ public final class PerformanceLevel extends Level { */ public static Level forDuration(long duration, final TimeUnit unit) { duration = unit.toNanos(duration); - if (duration < SLOW.minDuration) { + if (duration < SLOWNESS.minDuration) { return Level.FINE; // Most common case. } - return (duration >= SLOWER.minDuration) ? SLOWER : SLOW; + return (duration >= SLOWER.minDuration) ? SLOWER : SLOWNESS; } /** @@ -148,11 +156,11 @@ public final class PerformanceLevel extends Level { duration = unit.toNanos(duration); final int value = intValue(); synchronized (PerformanceLevel.class) { - if (value >= SLOWER.intValue() && duration < SLOW.minDuration) { - SLOW.minDuration = duration; + if (value >= SLOWER.intValue() && duration < SLOWNESS.minDuration) { + SLOWNESS.minDuration = duration; } minDuration = duration; - if (value <= SLOW.intValue() && duration > SLOWER.minDuration) { + if (value <= SLOWNESS.intValue() && duration > SLOWER.minDuration) { SLOWER.minDuration = duration; } } diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java index 37c1dc2052..48f224a8ff 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java @@ -1125,14 +1125,14 @@ public final class Vocabulary extends IndexedResourceBundle { public static final short SlashSeparatedList_2 = 181; /** - * Slow + * Slower */ - public static final short Slow = 267; + public static final short Slower = 268; /** - * Slower + * Slowness */ - public static final short Slower = 268; + public static final short Slowness = 267; /** * Source diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties index b5cb4e33b8..b4fe75867d 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties @@ -228,8 +228,8 @@ SampleDimensions = Sample dimensions Scale = Scale Simplified = Simplified SlashSeparatedList_2 = {0}/{1} -Slow = Slow Slower = Slower +Slowness = Slowness Source = Source SouthBound = South bound SpatialRepresentation = Spatial representation diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties index 348a8dabb1..940a4dfebc 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties @@ -235,8 +235,8 @@ SampleDimensions = Dimensions d\u2019\u00e9chantillonnage Scale = \u00c9chelle Simplified = Simplifi\u00e9 SlashSeparatedList_2 = {0}/{1} -Slow = Lent Slower = Plus lent +Slowness = Lenteur Source = Source SouthBound = Limite sud SpatialRepresentation = Repr\u00e9sentation spatiale diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/logging/PerformanceLevelTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/logging/PerformanceLevelTest.java index 5f2a11858f..831fc832cf 100644 --- a/core/sis-utility/src/test/java/org/apache/sis/util/logging/PerformanceLevelTest.java +++ b/core/sis-utility/src/test/java/org/apache/sis/util/logging/PerformanceLevelTest.java @@ -29,7 +29,7 @@ import static org.apache.sis.util.logging.PerformanceLevel.*; * Tests the {@link PerformanceLevel} class. * * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.3 * @since 0.3 * @module */ @@ -39,8 +39,8 @@ public final strictfp class PerformanceLevelTest extends TestCase { */ @Test public void testGetMinDuration() { - assertEquals(1, SLOW .getMinDuration(TimeUnit.SECONDS)); - assertEquals(10, SLOWER.getMinDuration(TimeUnit.SECONDS)); + assertEquals(1, SLOWNESS.getMinDuration(TimeUnit.SECONDS)); + assertEquals(10, SLOWER .getMinDuration(TimeUnit.SECONDS)); } /** @@ -48,23 +48,23 @@ public final strictfp class PerformanceLevelTest extends TestCase { */ @Test public void testSetMinDuration() { - final long t1 = SLOW .getMinDuration(TimeUnit.SECONDS); - final long t2 = SLOWER.getMinDuration(TimeUnit.SECONDS); + final long t1 = SLOWNESS.getMinDuration(TimeUnit.SECONDS); + final long t2 = SLOWER .getMinDuration(TimeUnit.SECONDS); try { - SLOW.setMinDuration(80, TimeUnit.SECONDS); - assertEquals(80, SLOW .getMinDuration(TimeUnit.SECONDS)); - assertEquals(80, SLOWER.getMinDuration(TimeUnit.SECONDS)); + SLOWNESS.setMinDuration(80, TimeUnit.SECONDS); + assertEquals(80, SLOWNESS.getMinDuration(TimeUnit.SECONDS)); + assertEquals(80, SLOWER .getMinDuration(TimeUnit.SECONDS)); SLOWER.setMinDuration(4, TimeUnit.SECONDS); - assertEquals(4, SLOW .getMinDuration(TimeUnit.SECONDS)); - assertEquals(4, SLOWER.getMinDuration(TimeUnit.SECONDS)); + assertEquals(4, SLOWNESS.getMinDuration(TimeUnit.SECONDS)); + assertEquals(4, SLOWER .getMinDuration(TimeUnit.SECONDS)); - SLOW.setMinDuration(6, TimeUnit.SECONDS); - assertEquals(6, SLOW .getMinDuration(TimeUnit.SECONDS)); - assertEquals(6, SLOWER.getMinDuration(TimeUnit.SECONDS)); + SLOWNESS.setMinDuration(6, TimeUnit.SECONDS); + assertEquals(6, SLOWNESS.getMinDuration(TimeUnit.SECONDS)); + assertEquals(6, SLOWER .getMinDuration(TimeUnit.SECONDS)); } finally { - SLOWER .setMinDuration(t1, TimeUnit.SECONDS); - SLOWER .setMinDuration(t2, TimeUnit.SECONDS); + SLOWER.setMinDuration(t1, TimeUnit.SECONDS); + SLOWER.setMinDuration(t2, TimeUnit.SECONDS); } } @@ -73,9 +73,9 @@ public final strictfp class PerformanceLevelTest extends TestCase { */ @Test public void testForDuration() { - assertSame(SLOW, forDuration( 2, TimeUnit.SECONDS)); - assertSame(SLOWER, forDuration(10, TimeUnit.SECONDS)); - assertSame(SLOWER , forDuration(20, TimeUnit.SECONDS)); - assertSame(FINE, forDuration(50, TimeUnit.MILLISECONDS)); + assertSame(SLOWNESS, forDuration( 2, TimeUnit.SECONDS)); + assertSame(SLOWER, forDuration(10, TimeUnit.SECONDS)); + assertSame(SLOWER, forDuration(20, TimeUnit.SECONDS)); + assertSame(FINE, forDuration(50, TimeUnit.MILLISECONDS)); } } diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractGridCoverageResource.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractGridCoverageResource.java index 35950832a0..5fa5ca7e38 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractGridCoverageResource.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractGridCoverageResource.java @@ -183,7 +183,7 @@ public abstract class AbstractGridCoverageResource extends AbstractResource impl /** * Logs the execution of a {@link #read(GridGeometry, int...)} operation. * The log level will be {@link Level#FINE} if the operation was quick enough, - * or {@link PerformanceLevel#SLOW} or higher level otherwise. + * or {@link PerformanceLevel#SLOWNESS} or higher level otherwise. * * @param file the file that was opened, or {@code null} for {@link StoreListeners#getSourceName()}. * @param domain domain of the created grid coverage.
