Commit e67da1b6 authored by Peter Kvitek's avatar Peter Kvitek Committed by Commit Bot

Introduced DevTools API Performance::SetTimeDomain().

DevTools performance metrics now allows collection and reporting of
duration related metrics using monotonically increasing abstract time
and thread running time.

Change-Id: Ica54cc291ba456c8dcc6a47a962e99a87cb8a475
Reviewed-on: https://chromium-review.googlesource.com/1247528Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595262}
parent 98207b17
...@@ -5485,6 +5485,18 @@ domain Performance ...@@ -5485,6 +5485,18 @@ domain Performance
# Enable collecting and reporting metrics. # Enable collecting and reporting metrics.
command enable command enable
# Sets time domain to use for collecting and reporting duration metrics.
# Note that this must be called before enabling metrics collection. Calling
# this method while metrics collection is enabled returns an error.
experimental command setTimeDomain
parameters
# Time domain
enum timeDomain
# Use monotonically increasing abstract time (default).
timeTicks
# Use thread running time.
threadTicks
# Retrieve current values of run-time metrics. # Retrieve current values of run-time metrics.
command getMetrics command getMetrics
returns returns
......
...@@ -83,11 +83,39 @@ void AppendMetric(protocol::Array<protocol::Performance::Metric>* container, ...@@ -83,11 +83,39 @@ void AppendMetric(protocol::Array<protocol::Performance::Metric>* container,
.setValue(value) .setValue(value)
.build()); .build());
} }
} // namespace
Response InspectorPerformanceAgent::setTimeDomain(const String& time_domain) {
if (enabled_.Get()) {
return Response::Error(
"Cannot set time domain while performance metrics collection"
" is enabled.");
}
TimeTicks GetTimeTicksNow() { using namespace protocol::Performance::SetTimeDomain;
return base::subtle::TimeTicksNowIgnoringOverride();
if (time_domain == TimeDomainEnum::TimeTicks) {
use_thread_ticks_ = false;
} else if (time_domain == TimeDomainEnum::ThreadTicks) {
if (!base::ThreadTicks::IsSupported()) {
return Response::Error("Thread time is not supported on this platform.");
}
base::ThreadTicks::WaitUntilInitialized();
use_thread_ticks_ = true;
} else {
return Response::Error("Invalid time domain specification.");
}
return Response::OK();
}
TimeTicks InspectorPerformanceAgent::GetTimeTicksNow() {
return use_thread_ticks_
? base::TimeTicks() +
base::TimeDelta::FromMicroseconds(
base::ThreadTicks::Now().since_origin().InMicroseconds())
: base::subtle::TimeTicksNowIgnoringOverride();
} }
} // namespace
Response InspectorPerformanceAgent::getMetrics( Response InspectorPerformanceAgent::getMetrics(
std::unique_ptr<protocol::Array<protocol::Performance::Metric>>* std::unique_ptr<protocol::Array<protocol::Performance::Metric>>*
......
...@@ -42,6 +42,7 @@ class CORE_EXPORT InspectorPerformanceAgent final ...@@ -42,6 +42,7 @@ class CORE_EXPORT InspectorPerformanceAgent final
// Performance protocol domain implementation. // Performance protocol domain implementation.
protocol::Response enable() override; protocol::Response enable() override;
protocol::Response disable() override; protocol::Response disable() override;
protocol::Response setTimeDomain(const String& time_domain) override;
protocol::Response getMetrics( protocol::Response getMetrics(
std::unique_ptr<protocol::Array<protocol::Performance::Metric>>* std::unique_ptr<protocol::Array<protocol::Performance::Metric>>*
out_result) override; out_result) override;
...@@ -69,6 +70,7 @@ class CORE_EXPORT InspectorPerformanceAgent final ...@@ -69,6 +70,7 @@ class CORE_EXPORT InspectorPerformanceAgent final
void ScriptStarts(); void ScriptStarts();
void ScriptEnds(); void ScriptEnds();
void InnerEnable(); void InnerEnable();
TimeTicks GetTimeTicksNow();
Member<InspectedFrames> inspected_frames_; Member<InspectedFrames> inspected_frames_;
TimeDelta layout_duration_; TimeDelta layout_duration_;
...@@ -85,6 +87,7 @@ class CORE_EXPORT InspectorPerformanceAgent final ...@@ -85,6 +87,7 @@ class CORE_EXPORT InspectorPerformanceAgent final
unsigned long long recalc_style_count_ = 0; unsigned long long recalc_style_count_ = 0;
int script_call_depth_ = 0; int script_call_depth_ = 0;
int layout_depth_ = 0; int layout_depth_ = 0;
bool use_thread_ticks_ = false;
InspectorAgentState::Boolean enabled_; InspectorAgentState::Boolean enabled_;
DISALLOW_COPY_AND_ASSIGN(InspectorPerformanceAgent); DISALLOW_COPY_AND_ASSIGN(InspectorPerformanceAgent);
}; };
......
...@@ -52,6 +52,7 @@ _CONFIG = [ ...@@ -52,6 +52,7 @@ _CONFIG = [
'base::Time', 'base::Time',
'base::TimeDelta', 'base::TimeDelta',
'base::TimeTicks', 'base::TimeTicks',
'base::ThreadTicks',
'base::UnguessableToken', 'base::UnguessableToken',
'base::UnsafeSharedMemoryRegion', 'base::UnsafeSharedMemoryRegion',
'base::WeakPtr', 'base::WeakPtr',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment