Skip to content

Commit

Permalink
AX: Add logging of time of execution to AXLogger.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=262992
<rdar://problem/116784445>

Reviewed by Tyler Wilcock.

Helpful to progile individual method performance.

* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::AXLogger::AXLogger):
(WebCore::AXLogger::~AXLogger):
* Source/WebCore/accessibility/AXLogger.h:

Canonical link: https://commits.webkit.org/269198@main
  • Loading branch information
AndresGonzalezApple committed Oct 11, 2023
1 parent 765dffe commit 5d5857e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Source/WebCore/accessibility/AXLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ AXLogger::AXLogger(const String& methodName)
if (!m_methodName.isEmpty())
LOG_WITH_STREAM(Accessibility, stream << m_methodName << " {");
}
m_startTime = MonotonicTime::now();
}

AXLogger::~AXLogger()
{
if (shouldLog()) {
if (!m_methodName.isEmpty())
LOG_WITH_STREAM(Accessibility, stream << "} " << m_methodName);
static const Seconds ExecutionTimeThreshold { 1_s };
auto elapsedTime = MonotonicTime::now() - m_startTime;
if (shouldLog() && !m_methodName.isEmpty()) {
if (elapsedTime > ExecutionTimeThreshold)
LOG_WITH_STREAM(Accessibility, stream << "} " << m_methodName << " exceeded ExecutionTimeThreshold " << elapsedTime);
else
LOG_WITH_STREAM(Accessibility, stream << "} " << m_methodName << " took " << elapsedTime);
}
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/accessibility/AXLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "AXCoreObject.h"
#include "AXObjectCache.h"
#include <wtf/MonotonicTime.h>

namespace WebCore {

Expand Down Expand Up @@ -69,6 +70,7 @@ class AXLogger {
private:
bool shouldLog();
String m_methodName;
MonotonicTime m_startTime;
};

#define AXTRACE(methodName) AXLogger axLogger(methodName)
Expand Down

0 comments on commit 5d5857e

Please sign in to comment.