mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1586 - ENH: Add TimedMetric.addSinceNanos() ... as a helper when using start nanos
This commit is contained in:
@@ -22,6 +22,11 @@ public interface TimedMetric {
|
||||
*/
|
||||
void addSinceNanos(long startNanos);
|
||||
|
||||
/**
|
||||
* Add a time event given the start nanos and bean count.
|
||||
*/
|
||||
void addSinceNanos(long startNanos, long beans);
|
||||
|
||||
/**
|
||||
* Return true if there are no metrics collected since the last collection.
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,11 @@ public interface TimedMetricMap {
|
||||
*/
|
||||
void addSinceNanos(String key, long startNanos);
|
||||
|
||||
/**
|
||||
* Add a time event given the start nanos and beans.
|
||||
*/
|
||||
void addSinceNanos(String key, long startNanos, int beans);
|
||||
|
||||
/**
|
||||
* Add an execution for the given key.
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,11 @@ class DTimedMetric implements TimedMetric {
|
||||
add((System.nanoTime() - startNanos) / 1000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSinceNanos(long startNanos, long beans) {
|
||||
add((System.nanoTime() - startNanos) / 1000L, beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value. Usually the value is Time or Bytes etc.
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,11 @@ class DTimedMetricMap implements TimedMetricMap {
|
||||
add(key, (System.nanoTime() - startNanos)/1000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSinceNanos(String key, long startNanos, int beans) {
|
||||
add(key, (System.nanoTime() - startNanos)/1000L, beans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(String key, long exeMicros) {
|
||||
map.computeIfAbsent(key, (k) -> new DTimedMetric(metricType, name + key)).add(exeMicros);
|
||||
|
||||
Reference in New Issue
Block a user