#1586 - ENH: Add TimedMetric.addSinceNanos() ... as a helper when using start nanos

This commit is contained in:
rob bygrave committed 2018-12-21 02:10:16 +13:00
1 parent 58f6c67d78
commit 0377e3ec5c
7 files changed
+76 -2

No files matched your search

@@ -35,6 +35,11 @@ class DTimedMetric implements TimedMetric {
this.name = name;
}
@Override
public void addSinceNanos(long startNanos) {
add((System.nanoTime() - startNanos) / 1000L);
}
/**
* Add a value. Usually the value is Time or Bytes etc.
*/
@@ -19,6 +19,11 @@ class DTimedMetricMap implements TimedMetricMap {
this.name = name;
}
@Override
public void addSinceNanos(String key, long startNanos) {
add(key, (System.nanoTime() - startNanos)/1000L);
}
@Override
public void add(String key, long exeMicros) {
map.computeIfAbsent(key, (k) -> new DTimedMetric(metricType, name + key)).add(exeMicros);