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

Measure duration #29824

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1f323a5
duration timing header and class
kaniughos Sep 9, 2023
8350434
added new measurements
kaniughos Sep 13, 2023
9250fd4
added network commissioning
kaniughos Sep 13, 2023
027dcec
Merge pull request #4 from kaniughos/measure-0913
kaniughos Sep 13, 2023
cb63620
testing timeval only
gitmtini Sep 25, 2023
810c891
testing systemtimeclock todo move dir
gitmtini Sep 25, 2023
3036a47
testing cronos impl
gitmtini Sep 26, 2023
d7e80b1
testing system clock timestamp in system dir
gitmtini Sep 26, 2023
43a4cde
sysclock compiles ; testing
gitmtini Sep 27, 2023
3d96109
sysclock compiles ; testing
gitmtini Sep 27, 2023
2fb8ebb
sysclock tested. works!
gitmtini Sep 28, 2023
4447869
rename timer and instance method
gitmtini Sep 29, 2023
43f79c2
tested esp32. Works!
kaniughos Sep 29, 2023
a342eb0
tested nRF and esp32 : Works!
gitmtini Sep 30, 2023
c29faeb
Merge pull request #5 from kaniughos/measure-sysclock-sysdir-0930
kaniughos Sep 30, 2023
7b13acc
Board auto-detection enabled timer
kaniughos Oct 5, 2023
f88777e
time duration calc bug
kaniughos Oct 9, 2023
0c9277a
use config flags to set impl flags
gitmtini Oct 11, 2023
2173b4c
use config flags to set impl flags
gitmtini Oct 12, 2023
bb1ff7f
testing toVal func
gitmtini Oct 15, 2023
9585994
system config works
gitmtini Oct 15, 2023
72a6ea8
test 2
kaniughos Oct 15, 2023
9c7f613
Merge branch 'measure-duration' into measure-duration-1015
kaniughos Oct 16, 2023
9ee154d
Merge pull request #6 from kaniughos/measure-duration-1015
kaniughos Oct 16, 2023
40e50b5
Merge branch 'project-chip:master' into measure-duration-1015
kaniughos Oct 16, 2023
1395a3a
added verbiage
kaniughos Oct 17, 2023
cad8d37
Merge pull request #7 from kaniughos/measure-duration-1015
kaniughos Oct 17, 2023
9ea6608
Merge branch 'master' into measure-duration
kaniughos Oct 17, 2023
5753a0d
boolean flags instead of defn checks
kaniughos Oct 18, 2023
19d8add
using systemclock
gitmtini Oct 21, 2023
f4af9b8
using systemclock
gitmtini Oct 21, 2023
6063af6
using systemclock
gitmtini Oct 22, 2023
d213e36
using systemclock
gitmtini Oct 22, 2023
9fd98d7
using systemclock
gitmtini Oct 23, 2023
a1b5e39
using systemclock
gitmtini Oct 23, 2023
a59ea9c
using systemclock
gitmtini Oct 24, 2023
cee31b7
using systemclock
gitmtini Oct 24, 2023
f6e7519
using systemclock
gitmtini Oct 24, 2023
b9eb258
using systemclock
gitmtini Oct 24, 2023
3e231cc
Update DurationTimer.cpp
kaniughos Oct 24, 2023
c472112
fix test warnings for multidevices
kaniughos Oct 25, 2023
85b1db4
Merge pull request #9 from kaniughos/measure-duration-1019-sytemclock
kaniughos Oct 25, 2023
01ddb37
Merge branch 'project-chip:master' into measure-duration
kaniughos Oct 25, 2023
8568185
Merge branch 'project-chip:master' into measure-duration
kaniughos Nov 17, 2023
cad3fde
merge master
kaniughos Jan 19, 2024
8db23f5
Merge pull request #10 from kaniughos/md_mergemaster
kaniughos Jan 19, 2024
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
1 change: 1 addition & 0 deletions scripts/tools/check_includes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@

# Only uses <chrono> for zero-cost types.
'src/system/SystemClock.h': {'chrono'},
'src/system/DurationTimer.h': {'string'},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is used in things that are used in embedded ... so you cannot use STL that uses HEAP. this is not allowed.

Overall this duration timer seems not something we want in the SDK since we have MATTER_TRACE_SCOPE that is for scoped tracing. You can create a "trace to log" and include some filters if you want to only trace specific things.

'src/platform/mbed/MbedEventTimeout.h': {'chrono'},

'src/app/app-platform/ContentApp.h': {'list', 'string'},
Expand Down
7 changes: 7 additions & 0 deletions src/app/CASESessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <app/CASESessionManager.h>
#include <lib/address_resolve/AddressResolve.h>
#include <system/DurationTimer.h>

namespace chip {

Expand All @@ -37,6 +38,10 @@ void CASESessionManager::FindOrEstablishSession(const ScopedNodeId & peerId, Cal
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
)
{

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "CASESessionManager: FindOrEstablishSession" );
timer.start();

ChipLogDetail(CASESessionManager, "FindOrEstablishSession: PeerId = [%d:" ChipLogFormatX64 "]", peerId.GetFabricIndex(),
ChipLogValueX64(peerId.GetNodeId()));

Expand Down Expand Up @@ -67,6 +72,8 @@ void CASESessionManager::FindOrEstablishSession(const ScopedNodeId & peerId, Cal
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES

session->Connect(onConnection, onFailure);

timer.stop();
}

void CASESessionManager::ReleaseSessionsForFabric(FabricIndex fabricIndex)
Expand Down
31 changes: 31 additions & 0 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <platform/PlatformManager.h>
#include <platform/internal/DeviceNetworkInfo.h>
#include <tracing/macros.h>
#include <system/DurationTimer.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -79,6 +80,7 @@ void Instance::Shutdown()

void Instance::InvokeCommand(HandlerContext & ctxt)
{

if (mAsyncCommandHandle.Get() != nullptr)
{
// We have a command processing in the backend, reject all incoming commands.
Expand Down Expand Up @@ -129,6 +131,8 @@ void Instance::InvokeCommand(HandlerContext & ctxt)
ctxt, [this](HandlerContext & ctx, const auto & req) { HandleReorderNetwork(ctx, req); });
return;
}


}

CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
Expand Down Expand Up @@ -216,6 +220,8 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & aPath, AttributeVal
void Instance::OnNetworkingStatusChange(NetworkCommissioning::Status aCommissioningError, Optional<ByteSpan> aNetworkId,
Optional<int32_t> aConnectStatus)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: OnNetworkingStatusChange ");
timer.start();
if (aNetworkId.HasValue() && aNetworkId.Value().size() > kMaxNetworkIDLen)
{
ChipLogError(DeviceLayer, "Invalid network id received when calling OnNetworkingStatusChange");
Expand All @@ -239,10 +245,13 @@ void Instance::OnNetworkingStatusChange(NetworkCommissioning::Status aCommission
{
mLastConnectErrorValue.SetNull();
}
timer.stop();
}

void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetworks::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleScanNetwork ");
timer.start();
MATTER_TRACE_SCOPE("HandleScanNetwork", "NetworkCommissioning");
if (mFeatureFlags.Has(Feature::kWiFiNetworkInterface))
{
Expand Down Expand Up @@ -282,6 +291,7 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::UnsupportedCommand);
}
timer.stop();
}

namespace {
Expand Down Expand Up @@ -315,6 +325,9 @@ bool CheckFailSafeArmed(CommandHandlerInterface::HandlerContext & ctx)

void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleAddOrUpdateWiFiNetwork ");
timer.start();

MATTER_TRACE_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");

VerifyOrReturn(CheckFailSafeArmed(ctx));
Expand Down Expand Up @@ -369,10 +382,13 @@ void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands
{
UpdateBreadcrumb(req.breadcrumb);
}
timer.stop();
}

void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleAddOrUpdateThreadNetwork ");
timer.start();
MATTER_TRACE_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");

VerifyOrReturn(CheckFailSafeArmed(ctx));
Expand All @@ -392,6 +408,7 @@ void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Comman
{
UpdateBreadcrumb(req.breadcrumb);
}
timer.stop();
}

void Instance::UpdateBreadcrumb(const Optional<uint64_t> & breadcrumb)
Expand All @@ -410,6 +427,9 @@ void Instance::CommitSavedBreadcrumb()

void Instance::HandleRemoveNetwork(HandlerContext & ctx, const Commands::RemoveNetwork::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleRemoveNetwork ");
timer.start();

MATTER_TRACE_SCOPE("HandleRemoveNetwork", "NetworkCommissioning");

VerifyOrReturn(CheckFailSafeArmed(ctx));
Expand All @@ -428,10 +448,15 @@ void Instance::HandleRemoveNetwork(HandlerContext & ctx, const Commands::RemoveN
{
UpdateBreadcrumb(req.breadcrumb);
}

timer.stop();
}

void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::ConnectNetwork::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleConnectNetwork ");
timer.start();

MATTER_TRACE_SCOPE("HandleConnectNetwork", "NetworkCommissioning");
if (req.networkID.size() > DeviceLayer::NetworkCommissioning::kMaxNetworkIDLen)
{
Expand All @@ -446,10 +471,15 @@ void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::Connec
mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler);
mCurrentOperationBreadcrumb = req.breadcrumb;
mpWirelessDriver->ConnectNetwork(req.networkID, this);

timer.stop();
}

void Instance::HandleReorderNetwork(HandlerContext & ctx, const Commands::ReorderNetwork::DecodableType & req)
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "NetworkCommissioning: HandleReorderNetwork ");
timer.start();

MATTER_TRACE_SCOPE("HandleReorderNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
MutableCharSpan debugText;
Expand All @@ -464,6 +494,7 @@ void Instance::HandleReorderNetwork(HandlerContext & ctx, const Commands::Reorde
{
UpdateBreadcrumb(req.breadcrumb);
}
timer.stop();
}

void Instance::OnResult(Status commissioningError, CharSpan debugText, int32_t interfaceStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <string.h>
#include <tracing/macros.h>
#include <system/DurationTimer.h>

using namespace chip;
using namespace ::chip::Transport;
Expand Down Expand Up @@ -413,6 +414,9 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle
ChipLogProgress(Zcl, "OpCreds: Received a RemoveFabric Command for FabricIndex 0x%x",
static_cast<unsigned>(fabricBeingRemoved));

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: RemoveFabric" );
timer.start();

if (!IsValidFabricIndex(fabricBeingRemoved))
{
ChipLogError(Zcl, "OpCreds: Failed RemoveFabric due to invalid FabricIndex");
Expand Down Expand Up @@ -460,6 +464,9 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle
CleanupSessionsForFabric(*sessionManager, fabricBeingRemoved);
}
}

timer.stop();

return true;
}

Expand All @@ -475,6 +482,9 @@ bool emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(app::CommandH

ChipLogProgress(Zcl, "OpCreds: Received an UpdateFabricLabel command");

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: UpdateFabricLabel" );
timer.start();

if (label.size() > 32)
{
ChipLogError(Zcl, "OpCreds: Failed UpdateFabricLabel due to invalid label size %u", static_cast<unsigned>(label.size()));
Expand Down Expand Up @@ -513,6 +523,9 @@ bool emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(app::CommandH
{
commandObj->AddStatus(commandPath, finalStatus);
}

timer.stop();

return true;
}

Expand Down Expand Up @@ -616,6 +629,9 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co

ChipLogProgress(Zcl, "OpCreds: Received an AddNOC command");

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: AddNOC" );
timer.start();

VerifyOrExit(NOCValue.size() <= Credentials::kMaxCHIPCertLength, nonDefaultStatus = Status::InvalidCommand);
VerifyOrExit(!ICACValue.HasValue() || ICACValue.Value().size() <= Credentials::kMaxCHIPCertLength,
nonDefaultStatus = Status::InvalidCommand);
Expand Down Expand Up @@ -756,6 +772,8 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co
ChipLogError(Zcl, "OpCreds: Failed AddNOC request with IM error 0x%02x", to_underlying(nonDefaultStatus));
}

timer.stop();

return true;
}

Expand All @@ -775,6 +793,9 @@ bool emberAfOperationalCredentialsClusterUpdateNOCCallback(app::CommandHandler *

ChipLogProgress(Zcl, "OpCreds: Received an UpdateNOC command");

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: UpdateNOC" );
timer.start();

auto & fabricTable = Server::GetInstance().GetFabricTable();
auto & failSafeContext = Server::GetInstance().GetFailSafeContext();
const FabricInfo * fabricInfo = RetrieveCurrentFabric(commandObj);
Expand Down Expand Up @@ -848,13 +869,19 @@ bool emberAfOperationalCredentialsClusterUpdateNOCCallback(app::CommandHandler *
ChipLogError(Zcl, "OpCreds: Failed UpdateNOC request with IM error 0x%02x", to_underlying(nonDefaultStatus));
}

timer.stop();

return true;
}

bool emberAfOperationalCredentialsClusterCertificateChainRequestCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::CertificateChainRequest::DecodableType & commandData)
{

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: Certificate Chain" );
timer.start();

MATTER_TRACE_SCOPE("CertificateChainRequest", "OperationalCredentials");
auto & certificateType = commandData.certificateType;

Expand Down Expand Up @@ -896,13 +923,19 @@ bool emberAfOperationalCredentialsClusterCertificateChainRequestCallback(
commandObj->AddStatus(commandPath, Status::Failure);
}

timer.stop();

return true;
}

bool emberAfOperationalCredentialsClusterAttestationRequestCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath,
const Commands::AttestationRequest::DecodableType & commandData)
{

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: AttestationRequest" );
timer.start();

MATTER_TRACE_SCOPE("AttestationRequest", "OperationalCredentials");
auto & attestationNonce = commandData.attestationNonce;

Expand Down Expand Up @@ -992,13 +1025,19 @@ bool emberAfOperationalCredentialsClusterAttestationRequestCallback(app::Command
to_underlying(finalStatus), err.Format());
}

timer.stop();

return true;
}

bool emberAfOperationalCredentialsClusterCSRRequestCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath,
const Commands::CSRRequest::DecodableType & commandData)
{

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: CSRRequest" );
timer.start();

MATTER_TRACE_SCOPE("CSRRequest", "OperationalCredentials");
ChipLogProgress(Zcl, "OpCreds: Received a CSRRequest command");

Expand Down Expand Up @@ -1127,13 +1166,19 @@ bool emberAfOperationalCredentialsClusterCSRRequestCallback(app::CommandHandler
to_underlying(finalStatus), err.Format());
}

timer.stop();

return true;
}

bool emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::AddTrustedRootCertificate::DecodableType & commandData)
{

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "OpCreds: AddTrustedRootCertificate" );
timer.start();

MATTER_TRACE_SCOPE("AddTrustedRootCertificate", "OperationalCredentials");

auto & fabricTable = Server::GetInstance().GetFabricTable();
Expand Down Expand Up @@ -1185,5 +1230,7 @@ bool emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(
}

commandObj->AddStatus(commandPath, finalStatus);
timer.stop();

return true;
}
5 changes: 5 additions & 0 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/DeviceControlServer.h>
#include <system/DurationTimer.h>

using namespace chip::app::Clusters;
using namespace chip::System::Clock;
Expand Down Expand Up @@ -234,6 +235,9 @@ CHIP_ERROR CommissioningWindowManager::OpenCommissioningWindow(Seconds16 commiss

CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()
{
chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "AppServer: AdvertiseAndListenForPASE" );
timer.start();

VerifyOrReturnError(mCommissioningTimeoutTimerArmed, CHIP_ERROR_INCORRECT_STATE);

mPairingSession.Clear();
Expand Down Expand Up @@ -273,6 +277,7 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()

ReturnErrorOnFailure(StartAdvertisement());

timer.stop();
return CHIP_NO_ERROR;
}

Expand Down
6 changes: 6 additions & 0 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <system/TimeSource.h>

#include <app/server/Server.h>
#include <system/DurationTimer.h>

namespace chip {
namespace app {
Expand Down Expand Up @@ -378,6 +379,9 @@ void DnssdServer::StopServer()
void DnssdServer::StartServer(Dnssd::CommissioningMode mode)
{
ChipLogProgress(Discovery, "Updating services using commissioning mode %d", static_cast<int>(mode));

chip::timing::DurationTimer timer = chip::timing::GetDefaultTimingInstance( "Discover: StartServer " );
timer.start();

DeviceLayer::PlatformMgr().AddEventHandler(OnPlatformEventWrapper, 0);

Expand Down Expand Up @@ -447,6 +451,8 @@ void DnssdServer::StartServer(Dnssd::CommissioningMode mode)
{
ChipLogError(Discovery, "Failed to finalize service update: %" CHIP_ERROR_FORMAT, err.Format());
}

timer.stop();
}

#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
Expand Down
Loading