rename future metrics

This commit is contained in:
Jaremy Creechley 2023-10-26 12:05:59 -07:00 committed by gmega
parent 8622befaf2
commit bde957e873
No known key found for this signature in database
GPG Key ID: FFD8DAF00660270F
1 changed files with 10 additions and 10 deletions

View File

@ -24,22 +24,22 @@ type
count*: int64 count*: int64
var var
futureDurations: Table[uint, FutureMetric] perFutureMetrics: Table[uint, FutureMetric]
callbackDurations: Table[ptr SrcLoc, CallbackMetric] callbackDurations: Table[ptr SrcLoc, CallbackMetric]
proc setFutureCreate(fut: FutureBase) {.raises: [].} = proc setFutureCreate(fut: FutureBase) {.raises: [].} =
## used for setting the duration ## used for setting the duration
let loc = fut.internalLocation[Create] let loc = fut.internalLocation[Create]
futureDurations[fut.id] = FutureMetric() perFutureMetrics[fut.id] = FutureMetric()
futureDurations.withValue(fut.id, metric): perFutureMetrics.withValue(fut.id, metric):
metric.created = Moment.now() metric.created = Moment.now()
echo loc, "; future create " echo loc, "; future create "
proc setFutureStart(fut: FutureBase) {.raises: [].} = proc setFutureStart(fut: FutureBase) {.raises: [].} =
## used for setting the duration ## used for setting the duration
let loc = fut.internalLocation[Create] let loc = fut.internalLocation[Create]
assert futureDurations.hasKey(fut.id) assert perFutureMetrics.hasKey(fut.id)
futureDurations.withValue(fut.id, metric): perFutureMetrics.withValue(fut.id, metric):
let ts = Moment.now() let ts = Moment.now()
metric.start = some ts metric.start = some ts
metric.blocks.inc() metric.blocks.inc()
@ -52,11 +52,11 @@ proc setFuturePause(fut, child: FutureBase) {.raises: [].} =
var durationChildren = ZeroDuration var durationChildren = ZeroDuration
var initDurationChildren = ZeroDuration var initDurationChildren = ZeroDuration
if childLoc != nil: if childLoc != nil:
futureDurations.withValue(child.id, metric): perFutureMetrics.withValue(child.id, metric):
durationChildren = metric.duration durationChildren = metric.duration
initDurationChildren = metric.initDuration initDurationChildren = metric.initDuration
assert futureDurations.hasKey(fut.id) assert perFutureMetrics.hasKey(fut.id)
futureDurations.withValue(fut.id, metric): perFutureMetrics.withValue(fut.id, metric):
if metric.start.isSome: if metric.start.isSome:
let ts = Moment.now() let ts = Moment.now()
metric.duration += ts - metric.start.get() metric.duration += ts - metric.start.get()
@ -77,8 +77,8 @@ proc setFutureDuration(fut: FutureBase) {.raises: [].} =
let loc = fut.internalLocation[Create] let loc = fut.internalLocation[Create]
# assert "set duration: " & $loc # assert "set duration: " & $loc
var fm: FutureMetric var fm: FutureMetric
# assert futureDurations.pop(fut.id, fm) # assert perFutureMetrics.pop(fut.id, fm)
futureDurations.withValue(fut.id, metric): perFutureMetrics.withValue(fut.id, metric):
fm = metric[] fm = metric[]
discard callbackDurations.hasKeyOrPut(loc, CallbackMetric(minSingleTime: InfiniteDuration)) discard callbackDurations.hasKeyOrPut(loc, CallbackMetric(minSingleTime: InfiniteDuration))