mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 1103915: Output absolute starting time in the captured TaskTracer profile. r=tlee
--HG-- extra : rebase_source : e258ea3548ee4d7f3d806eeb7b4a53daa9061dc1
This commit is contained in:
parent
0df1801282
commit
08345c74b7
@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "nsString.h"
|
||||
@ -26,8 +27,6 @@ static pid_t gettid()
|
||||
}
|
||||
#endif
|
||||
|
||||
using mozilla::TimeStamp;
|
||||
|
||||
namespace mozilla {
|
||||
namespace tasktracer {
|
||||
|
||||
@ -35,12 +34,18 @@ static mozilla::ThreadLocal<TraceInfo*>* sTraceInfoTLS = nullptr;
|
||||
static mozilla::StaticMutex sMutex;
|
||||
static nsTArray<nsAutoPtr<TraceInfo>>* sTraceInfos = nullptr;
|
||||
static bool sIsLoggingStarted = false;
|
||||
static PRTime sStartTime;
|
||||
|
||||
static TimeStamp sStartTime;
|
||||
static const char sJSLabelPrefix[] = "#tt#";
|
||||
|
||||
namespace {
|
||||
|
||||
static PRTime
|
||||
GetTimestamp()
|
||||
{
|
||||
return PR_Now() / 1000;
|
||||
}
|
||||
|
||||
static TraceInfo*
|
||||
AllocTraceInfo(int aTid)
|
||||
{
|
||||
@ -172,12 +177,6 @@ IsStartLogging(TraceInfo* aInfo)
|
||||
return aInfo ? aInfo->mStartLogging : false;
|
||||
}
|
||||
|
||||
static PRInt64
|
||||
DurationFromStart()
|
||||
{
|
||||
return static_cast<PRInt64>((TimeStamp::Now() - sStartTime).ToMilliseconds());
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
nsCString*
|
||||
@ -291,8 +290,8 @@ LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId, uint64_t aSourceEventId,
|
||||
nsCString* log = info->AppendLog();
|
||||
if (log) {
|
||||
log->AppendPrintf("%d %lld %lld %lld %d %lld",
|
||||
ACTION_DISPATCH, aTaskId, DurationFromStart(),
|
||||
aSourceEventId, aSourceEventType, aParentTaskId);
|
||||
ACTION_DISPATCH, aTaskId, GetTimestamp(), aSourceEventId,
|
||||
aSourceEventType, aParentTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +308,7 @@ LogBegin(uint64_t aTaskId, uint64_t aSourceEventId)
|
||||
nsCString* log = info->AppendLog();
|
||||
if (log) {
|
||||
log->AppendPrintf("%d %lld %lld %d %d",
|
||||
ACTION_BEGIN, aTaskId, DurationFromStart(), getpid(), gettid());
|
||||
ACTION_BEGIN, aTaskId, GetTimestamp(), getpid(), gettid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,8 +324,7 @@ LogEnd(uint64_t aTaskId, uint64_t aSourceEventId)
|
||||
// [2 taskId endTime]
|
||||
nsCString* log = info->AppendLog();
|
||||
if (log) {
|
||||
log->AppendPrintf("%d %lld %lld", ACTION_END, aTaskId,
|
||||
DurationFromStart());
|
||||
log->AppendPrintf("%d %lld %lld", ACTION_END, aTaskId, GetTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,16 +384,16 @@ void AddLabel(const char* aFormat, ...)
|
||||
nsCString* log = info->AppendLog();
|
||||
if (log) {
|
||||
log->AppendPrintf("%d %lld %lld \"%s\"", ACTION_ADD_LABEL, info->mCurTaskId,
|
||||
DurationFromStart(), buffer.get());
|
||||
GetTimestamp(), buffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
// Functions used by GeckoProfiler.
|
||||
|
||||
void
|
||||
StartLogging(TimeStamp aStartTime)
|
||||
StartLogging()
|
||||
{
|
||||
sStartTime = aStartTime;
|
||||
sStartTime = GetTimestamp();
|
||||
SetLogStarted(true);
|
||||
}
|
||||
|
||||
@ -406,7 +404,7 @@ StopLogging()
|
||||
}
|
||||
|
||||
TraceInfoLogsType*
|
||||
GetLoggedData(TimeStamp aStartTime)
|
||||
GetLoggedData()
|
||||
{
|
||||
TraceInfoLogsType* result = new TraceInfoLogsType();
|
||||
|
||||
@ -420,6 +418,12 @@ GetLoggedData(TimeStamp aStartTime)
|
||||
return result;
|
||||
}
|
||||
|
||||
const PRTime
|
||||
GetStartTime()
|
||||
{
|
||||
return sStartTime;
|
||||
}
|
||||
|
||||
const char*
|
||||
GetJSLabelPrefix()
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define GECKO_TASK_TRACER_H
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
/**
|
||||
* TaskTracer provides a way to trace the correlation between different tasks
|
||||
@ -64,10 +63,13 @@ public:
|
||||
// followed by corresponding parameters.
|
||||
void AddLabel(const char* aFormat, ...);
|
||||
|
||||
void StartLogging(mozilla::TimeStamp aStartTime);
|
||||
void StartLogging();
|
||||
void StopLogging();
|
||||
nsTArray<nsCString>* GetLoggedData(TimeStamp aStartTime);
|
||||
|
||||
// Returns the timestamp when Task Tracer is enabled in this process.
|
||||
const PRTime GetStartTime();
|
||||
|
||||
/**
|
||||
* Internal functions.
|
||||
*/
|
||||
|
@ -119,7 +119,6 @@ void TableTicker::StreamTaskTracer(JSStreamWriter& b)
|
||||
for (uint32_t i = 0; i < data->Length(); ++i) {
|
||||
b.Value((data->ElementAt(i)).get());
|
||||
}
|
||||
mozilla::tasktracer::StartLogging(sStartTime);
|
||||
b.EndArray();
|
||||
|
||||
b.Name("threads");
|
||||
@ -139,6 +138,9 @@ void TableTicker::StreamTaskTracer(JSStreamWriter& b)
|
||||
b.EndObject();
|
||||
}
|
||||
b.EndArray();
|
||||
|
||||
b.NameValue("start",
|
||||
static_cast<double>(mozilla::tasktracer::GetStartTime()));
|
||||
#endif
|
||||
b.EndObject();
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class TableTicker: public Sampler {
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
if (mTaskTracer) {
|
||||
mozilla::tasktracer::StartLogging(sStartTime);
|
||||
mozilla::tasktracer::StartLogging();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user