Skip to content

Commit

Permalink
[Darwin] Followup PR for missed code review comments (project-chip#32447
Browse files Browse the repository at this point in the history
)

* [Darwin] Followup PR for missed code review comments

- Fixes following issues:  project-chip#32438, project-chip#32443, project-chip#32439

* Resytler fixes

* Address review comment
  • Loading branch information
anush-apple authored and huangxuyong committed Mar 19, 2024
1 parent 1922a21 commit 6b8f7ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/darwin/Framework/CHIP/MTRMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ MTR_NEWLY_AVAILABLE
@property (nonatomic, nullable, readonly, copy) NSNumber * value;

/**
* Error code for the metric data. This value when valid, holds the error code value
* of the operation associated with the event.
* Error code for the metric data. This value, when not nil, holds the error code value
* of the operation associated with the event. Interpretation of the error code value
* dependents on the metric being emitted.
*/
@property (nonatomic, nullable, readonly, copy) NSNumber * errorCode;

/**
* Duration of event associated with the metric. This value may be nil depending on
* the event emitted.
* the event emitted. When not nil, the value of duration is of type NSTimeInterval.
*/
@property (nonatomic, nullable, readonly, copy) NSNumber * durationMicroseconds;
@property (nonatomic, nullable, readonly, copy) NSNumber * duration;

@end

Expand Down
6 changes: 3 additions & 3 deletions src/darwin/Framework/CHIP/MTRMetricsCollector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ - (instancetype)initWithMetricEvent:(const MetricEvent &)event
- (void)setDurationFromMetricDataAndClearCounters:(MTRMetricData *)fromData
{
auto duration = _timePoint - fromData->_timePoint;
_durationMicroseconds = [NSNumber numberWithUnsignedLongLong:duration.count()];
_duration = [NSNumber numberWithDouble:double(duration.count()) / USEC_PER_SEC];

// Clear timepoints to minimize history
_timePoint = fromData->_timePoint = chip::System::Clock::Microseconds64(0);
}

- (NSString *)description
{
return [NSString stringWithFormat:@"<MTRMetricData>: Type %d, Value = %@, Error Code = %@, Duration = %@ us",
static_cast<int>(_type), self.value, self.errorCode, self.durationMicroseconds];
return [NSString stringWithFormat:@"<MTRMetricData: Type %d, Value = %@, Error Code = %@, Duration = %@ us>",
static_cast<int>(_type), self.value, self.errorCode, self.duration];
}

@end
Expand Down

0 comments on commit 6b8f7ff

Please sign in to comment.