diff --git a/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h b/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h index 9e76c680528a37..7d5a8520a3355a 100644 --- a/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h +++ b/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h @@ -36,6 +36,10 @@ template class CHIPCallbackBridge { , mSuccess(OnSuccessFn, this) , mFailure(OnFailureFn, this) { + mRequestTime = [NSDate date]; + // Generate a unique cookie to track this operation + mCookie = [NSString stringWithFormat:@"Response Time: %s+%u", typeid(T).name(), arc4random()]; + ChipLogDetail(Controller, "%s", mCookie.UTF8String); __block CHIP_ERROR err = CHIP_NO_ERROR; dispatch_sync(chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{ err = action(mSuccess.Cancel(), mFailure.Cancel()); @@ -81,6 +85,8 @@ template class CHIPCallbackBridge { } dispatch_async(callbackBridge->mQueue, ^{ + ChipLogDetail(Controller, "%s %f seconds", callbackBridge->mCookie.UTF8String, + -[callbackBridge->mRequestTime timeIntervalSinceNow]); callbackBridge->mHandler(value, error); if (!callbackBridge->mKeepAlive) { @@ -94,4 +100,8 @@ template class CHIPCallbackBridge { chip::Callback::Callback mSuccess; chip::Callback::Callback mFailure; + + // Measure the time it took for the callback to trigger + NSDate * mRequestTime; + NSString * mCookie; };