Skip to content

Commit

Permalink
299: Benchmark using JMH or similar
Browse files Browse the repository at this point in the history
Task-Url: #299
  • Loading branch information
keilw committed Aug 6, 2020
1 parent 0630757 commit c8ae627
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a>
* @author <a href="mailto:[email protected]">Otavio Santana</a>
* @version 1.3, $Date: 2018-11-02 $
* @version 1.4, $Date: 2020-08-06 $
* @since 1.0
*/
public class DefaultQuantityFactory<Q extends Quantity<Q>> implements QuantityFactory<Q> {
@SuppressWarnings("rawtypes")
static final Map<Class, QuantityFactory> INSTANCES = new HashMap<>();

static final Logger logger = Logger.getLogger(DefaultQuantityFactory.class.getName());
static final Logger LOGGER = Logger.getLogger(DefaultQuantityFactory.class.getName());

static final Level LOG_LEVEL = Level.FINE;
static final Level DEFAULT_LOG_LEVEL = Level.FINER;

/**
* The type of the quantities created by this factory.
Expand Down Expand Up @@ -151,6 +151,11 @@ public class DefaultQuantityFactory<Q extends Quantity<Q>> implements QuantityFa
CLASS_TO_SYSTEM_UNIT.put(Acceleration.class, METRE_PER_SQUARE_SECOND);
CLASS_TO_SYSTEM_UNIT.put(Area.class, SQUARE_METRE);
CLASS_TO_SYSTEM_UNIT.put(Volume.class, CUBIC_METRE);

if (LOGGER.isLoggable(Level.CONFIG)) {
LOGGER.config(String.format("Registered quantity types: %s",
CLASS_TO_SYSTEM_UNIT.keySet()));
}
}

@SuppressWarnings("unchecked")
Expand All @@ -170,7 +175,7 @@ private DefaultQuantityFactory(Class<Q> quantity) {
*/
@SuppressWarnings("unchecked")
public static <Q extends Quantity<Q>> QuantityFactory<Q> getInstance(final Class<Q> type) {
logger.log(LOG_LEVEL, "Type: " + type + ": " + type.isInterface());
LOGGER.log(DEFAULT_LOG_LEVEL, "Type: " + type + ": " + type.isInterface());
QuantityFactory<Q> factory;
factory = INSTANCES.get(type);
if (factory != null) {
Expand Down

0 comments on commit c8ae627

Please sign in to comment.