mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#1586 - ENH: Add TimedMetric.addSinceNanos() ... as a helper when using start nanos
This commit is contained in:
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);
|
||||
|
||||
Reference in new issue
Block a user