Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track Matter operation times for the Darwin layer #15110

Merged
merged 3 commits into from
Feb 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ template <class T> 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());
Expand Down Expand Up @@ -81,6 +85,8 @@ template <class T> class CHIPCallbackBridge {
}

dispatch_async(callbackBridge->mQueue, ^{
ChipLogDetail(Controller, "%s %f seconds", callbackBridge->mCookie.UTF8String,
-[callbackBridge->mRequestTime timeIntervalSinceNow]);
callbackBridge->mHandler(value, error);

if (!callbackBridge->mKeepAlive) {
Expand All @@ -94,4 +100,8 @@ template <class T> class CHIPCallbackBridge {

chip::Callback::Callback<T> mSuccess;
chip::Callback::Callback<CHIPDefaultFailureCallbackType> mFailure;

// Measure the time it took for the callback to trigger
NSDate * mRequestTime;
NSString * mCookie;
};