Commit b05c5896 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[coverage] Report timestamp on coverage updates

This CL adds timestamps to coverage updates. This is useful for clients,
because between requesting a coverage update and collecting coverage data
significant time may pass. This change allows precise attribution at what
time a coverage update was taken.

Change-Id: I65a9cccb0171e892b7dbe35d105d3ca246ba08d0
Bug: chromium:1022031
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1992435Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65696}
parent 25f242ad
......@@ -824,6 +824,9 @@ domain Profiler
optional boolean callCount
# Collect block-based coverage.
optional boolean detailed
returns
# The timestamp (in milliseconds) the coverage update was taken in the backend.
number timestamp
# Enable type profile.
experimental command startTypeProfile
......@@ -846,6 +849,8 @@ domain Profiler
returns
# Coverage data for the current isolate.
array of ScriptCoverage result
# The timestamp (in milliseconds) the coverage update was taken in the backend.
number timestamp
# Collect type profile.
experimental command takeTypeProfile
......
......@@ -7,8 +7,9 @@ include_rules = [
"+src/base/macros.h",
"+src/base/memory.h",
"+src/base/optional.h",
"+src/base/platform/platform.h",
"+src/base/platform/mutex.h",
"+src/base/platform/platform.h",
"+src/base/platform/time.h",
"+src/base/safe_conversions.h",
"+src/base/template-utils.h",
"+src/base/v8-fallthrough.h",
......
......@@ -7,6 +7,7 @@
#include <vector>
#include "src/base/atomicops.h"
#include "src/base/platform/time.h"
#include "src/debug/debug-interface.h"
#include "src/inspector/protocol/Protocol.h"
#include "src/inspector/string-util.h"
......@@ -260,7 +261,9 @@ void V8ProfilerAgentImpl::restore() {
ProfilerAgentState::preciseCoverageCallCount, false);
bool detailed = m_state->booleanProperty(
ProfilerAgentState::preciseCoverageDetailed, false);
startPreciseCoverage(Maybe<bool>(callCount), Maybe<bool>(detailed));
double timestamp;
startPreciseCoverage(Maybe<bool>(callCount), Maybe<bool>(detailed),
&timestamp);
}
}
......@@ -292,8 +295,12 @@ Response V8ProfilerAgentImpl::stop(
}
Response V8ProfilerAgentImpl::startPreciseCoverage(Maybe<bool> callCount,
Maybe<bool> detailed) {
Maybe<bool> detailed,
double* out_timestamp) {
if (!m_enabled) return Response::Error("Profiler is not enabled");
*out_timestamp =
(v8::base::TimeTicks::HighResolutionNow() - v8::base::TimeTicks())
.InMilliseconds();
bool callCountValue = callCount.fromMaybe(false);
bool detailedValue = detailed.fromMaybe(false);
m_state->setBoolean(ProfilerAgentState::preciseCoverageStarted, true);
......@@ -395,13 +402,17 @@ Response coverageToProtocol(
Response V8ProfilerAgentImpl::takePreciseCoverage(
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) {
out_result,
double* out_timestamp) {
if (!m_state->booleanProperty(ProfilerAgentState::preciseCoverageStarted,
false)) {
return Response::Error("Precise coverage has not been started.");
}
v8::HandleScope handle_scope(m_isolate);
v8::debug::Coverage coverage = v8::debug::Coverage::CollectPrecise(m_isolate);
*out_timestamp =
(v8::base::TimeTicks::HighResolutionNow() - v8::base::TimeTicks())
.InMilliseconds();
return coverageToProtocol(m_session->inspector(), coverage, out_result);
}
......
......@@ -39,12 +39,13 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
Response start() override;
Response stop(std::unique_ptr<protocol::Profiler::Profile>*) override;
Response startPreciseCoverage(Maybe<bool> binary,
Maybe<bool> detailed) override;
Response startPreciseCoverage(Maybe<bool> binary, Maybe<bool> detailed,
double* out_timestamp) override;
Response stopPreciseCoverage() override;
Response takePreciseCoverage(
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) override;
out_result,
double* out_timestamp) override;
Response getBestEffortCoverage(
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) override;
......
......@@ -6,6 +6,7 @@ Running test: testPreciseCountBaseline
result : {
result : [
]
timestamp : <timestamp>
}
}
{
......@@ -13,6 +14,7 @@ Running test: testPreciseCountBaseline
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -109,6 +111,7 @@ Running test: testPreciseCountCoverage
url :
}
]
timestamp : <timestamp>
}
}
{
......@@ -116,6 +119,7 @@ Running test: testPreciseCountCoverage
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -195,6 +199,7 @@ Running test: testPreciseCountCoverageIncremental
url : testPreciseCountCoverageIncremental
}
]
timestamp : <timestamp>
}
}
{
......@@ -312,6 +317,7 @@ Running test: testPreciseCountCoverageIncremental
url :
}
]
timestamp : <timestamp>
}
}
......@@ -711,6 +717,7 @@ Running test: testEnablePreciseCountCoverageAtPause
url :
}
]
timestamp : <timestamp>
}
}
......@@ -780,6 +787,7 @@ Running test: testPreciseBinaryCoverage
url : testPreciseBinaryCoverage
}
]
timestamp : <timestamp>
}
}
{
......@@ -866,6 +874,7 @@ Running test: testPreciseBinaryCoverage
url :
}
]
timestamp : <timestamp>
}
}
......@@ -875,6 +884,7 @@ Running test: testPreciseEmptyScriptCoverageEntries
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -975,6 +985,7 @@ Running test: testPreciseCountCoveragePartial
url : testPreciseCountCoveragePartial
}
]
timestamp : <timestamp>
}
}
{
......@@ -1027,5 +1038,6 @@ Running test: testPreciseCountCoveragePartial
url :
}
]
timestamp : <timestamp>
}
}
......@@ -6,6 +6,7 @@ Running test: testPreciseCountBaseline
result : {
result : [
]
timestamp : <timestamp>
}
}
{
......@@ -13,6 +14,7 @@ Running test: testPreciseCountBaseline
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -99,6 +101,7 @@ Running test: testPreciseCountCoverage
url :
}
]
timestamp : <timestamp>
}
}
{
......@@ -106,6 +109,7 @@ Running test: testPreciseCountCoverage
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -505,6 +509,7 @@ Running test: testEnablePreciseCountCoverageAtPause
url :
}
]
timestamp : <timestamp>
}
}
......@@ -574,6 +579,7 @@ Running test: testPreciseBinaryCoverage
url : testPreciseBinaryCoverage
}
]
timestamp : <timestamp>
}
}
{
......@@ -660,6 +666,7 @@ Running test: testPreciseBinaryCoverage
url :
}
]
timestamp : <timestamp>
}
}
......@@ -669,6 +676,7 @@ Running test: testPreciseEmptyScriptCoverageEntries
result : {
result : [
]
timestamp : <timestamp>
}
}
......@@ -769,6 +777,7 @@ Running test: testPreciseCountCoveragePartial
url : testPreciseCountCoveragePartial
}
]
timestamp : <timestamp>
}
}
{
......@@ -821,5 +830,6 @@ Running test: testPreciseCountCoveragePartial
url :
}
]
timestamp : <timestamp>
}
}
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