Skip to content

Commit

Permalink
Downgrade SO to ubuntu 20.04
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldobapvicjr committed Apr 6, 2024
1 parent e59a36a commit eae01fa
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
java_version: [ 11, 17, 21 ]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ Performetrics provides two different conversion modes that can be applied depend
* **Fast conversion**: uses Java-standard classes to convert durations to different time units. Although conversions in this mode are extremely fast, those from finer to coarser granularities truncate, so lose precision. For example, converting 999 milliseconds to seconds results in 0 (worst case).
To set this mode, call `Performetrics.setDefaultConversionMode(ConversionMode.FAST)`.
To set this mode, call `Performetrics.configuration().setDefaultConversionMode(ConversionMode.FAST)`.
* **Double-precision (default)**: implements a more robust conversion logic that avoids truncation from finer to coarser granularity. For example, converting 999 milliseconds to seconds results in 0.999
A initial precision of 9 decimal places is set by default. This property can be changed calling `Performetrics.setScale(int)`.
A initial precision of 9 decimal places is set by default. This property can be changed calling `Performetrics.configuration().setScale(int)`.
> **Note:** Check the **[Javadoc](https://javadoc.io/doc/net.obvj/performetrics)** to find out how to specify a different conversion mode for a single operation.
Expand Down
41 changes: 39 additions & 2 deletions src/main/java/net/obvj/performetrics/Performetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import net.obvj.performetrics.Counter.Type;
import net.obvj.performetrics.config.Configuration;
import net.obvj.performetrics.config.ConfigurationHolder;
import net.obvj.performetrics.monitors.MonitoredRunnable;
import net.obvj.performetrics.util.print.PrintStyle;
Expand Down Expand Up @@ -48,12 +49,27 @@ private Performetrics()
throw new IllegalStateException("Instantiation not allowed");
}

/**
* Returns the current {@link Configuration}.
*
* @return the current configuration
* @since 2.5.3
*/
public Configuration configuration()
{
return ConfigurationHolder.getConfiguration();
}

/**
* Sets a conversion mode to be applied by supported operations if no specific mode is
* set.
*
* @param conversionMode the {@link ConversionMode} to set
*
* @deprecated Use {@code Performetrics.configuration().setConversionMode(ConversionMode)}
* instead.
*/
@Deprecated(since = "2.5.3", forRemoval = true)
public static void setDefaultConversionMode(ConversionMode conversionMode)
{
ConfigurationHolder.getConfiguration().setConversionMode(conversionMode);
Expand All @@ -65,7 +81,10 @@ public static void setDefaultConversionMode(ConversionMode conversionMode)
*
* @param scale a number between 0 and 16 to be set
* @throws IllegalArgumentException if a number outside the allowed range is received
*
* @deprecated Use {@code Performetrics.configuration().setScale(int)} instead.
*/
@Deprecated(since = "2.5.3", forRemoval = true)
public static void setScale(int scale)
{
ConfigurationHolder.getConfiguration().setScale(scale);
Expand All @@ -85,7 +104,11 @@ public static void setScale(int scale)
* @throws NullPointerException if the specified {@code PrintStyle} is null
*
* @since 2.4.0
*
* @deprecated Use {@code Performetrics.configuration().setPrintStyle(PrintStyle)}
* instead.
*/
@Deprecated(since = "2.5.3", forRemoval = true)
public static void setDefaultPrintStyle(PrintStyle printStyle)
{
ConfigurationHolder.getConfiguration().setPrintStyle(printStyle);
Expand All @@ -105,7 +128,12 @@ public static void setDefaultPrintStyle(PrintStyle printStyle)
* @throws NullPointerException if the specified {@code PrintStyle} is null
*
* @since 2.2.1
*
* @deprecated Use
* {@code Performetrics.configuration().setPrintStyleForSummary(PrintStyle)}
* instead.
*/
@Deprecated(since = "2.5.3", forRemoval = true)
public static void setDefaultPrintStyleForSummary(PrintStyle printStyle)
{
ConfigurationHolder.getConfiguration().setPrintStyleForSummary(printStyle);
Expand All @@ -125,7 +153,12 @@ public static void setDefaultPrintStyleForSummary(PrintStyle printStyle)
* @throws NullPointerException if the specified {@code PrintStyle} is null
*
* @since 2.2.1
*
* @deprecated Use
* {@code Performetrics.configuration().setPrintStyleForDetails(PrintStyle)}
* instead.
*/
@Deprecated(since = "2.5.3", forRemoval = true)
public static void setDefaultPrintStyleForDetails(PrintStyle printStyle)
{
ConfigurationHolder.getConfiguration().setPrintStyleForDetails(printStyle);
Expand All @@ -141,8 +174,12 @@ public static void setDefaultPrintStyleForDetails(PrintStyle printStyle)
*
* <pre>
* {@code MonitoredRunnable runnable =}
* {@code Performetrics.monitorOperation(() -> myObj.exec());}
* {@code Duration elapsedTime = runnable.elapsedTime(Type.WALL_CLOCK_TIME);}
* {@code
* Performetrics.monitorOperation(() -> myObj.exec());
* }
* {@code
* Duration elapsedTime = runnable.elapsedTime(Type.WALL_CLOCK_TIME);
* }
* </pre>
*
* </blockquote>
Expand Down

0 comments on commit eae01fa

Please sign in to comment.