Bug 1159486 - Make profiler use the process creation time. r=shu, r=jsantell

This commit is contained in:
Tom Tromey 2015-06-16 22:28:00 -04:00
parent e1b6317a78
commit 42f21664cb
20 changed files with 98 additions and 89 deletions

View File

@ -119,10 +119,14 @@ ProfilerFrontFacade.prototype = {
interval: options.sampleFrequency ? (1000 / (options.sampleFrequency * 1000)) : void 0
};
yield this.startProfiler(profilerOptions);
let startInfo = yield this.startProfiler(profilerOptions);
let startTime = 0;
if ('currentTime' in startInfo) {
startTime = startInfo.currentTime;
}
this.emit("profiler-activated");
return { startTime: 0, position, generation, totalSize };
return { startTime, position, generation, totalSize };
}),
/**

View File

@ -144,7 +144,6 @@ RecordingModel.prototype = {
// since the profiler is continuously running. Because of this, sample
// times are not guaranteed to have a zero epoch, so offset the
// timestamps.
// TODO move this into FakeProfilerFront in ./actors.js after bug 1154115
RecordingUtils.offsetSampleTimes(this._profile, this._profilerStartTime);
// Markers need to be sorted ascending by time, to be properly displayed

View File

@ -37,8 +37,6 @@ function* spawnTest() {
yield front.stopRecording(firstRecording);
info("The first recording is " + firstRecording.getDuration() + "ms long.");
is(firstRecordingStartTime, 0,
"The profiling start time should be 0 for the first recording.");
ok(firstRecording.getDuration() >= WAIT_TIME,
"The first recording duration is correct.");

View File

@ -22,8 +22,6 @@ function* spawnTest() {
yield front.stopRecording(firstRecording);
is(firstRecordingStartTime, 0,
"The profiling start time should be 0 for the first recording.");
ok(firstRecording.getDuration() >= WAIT_TIME,
"The first recording duration is correct.");

View File

@ -99,6 +99,10 @@ ProfilerActor.prototype = {
threadFilters: request.threadFilters || DEFAULT_PROFILER_OPTIONS.threadFilters,
};
// The start time should be before any samples we might be
// interested in.
let currentTime = nsIProfilerModule.getElapsedTime();
nsIProfilerModule.StartProfiler(
options.entries,
options.interval,
@ -109,7 +113,7 @@ ProfilerActor.prototype = {
);
let { position, totalSize, generation } = this.onGetBufferInfo();
return { started: true, position, totalSize, generation };
return { started: true, position, totalSize, generation, currentTime };
},
/**

View File

@ -165,18 +165,18 @@ static inline void profiler_responsiveness(const mozilla::TimeStamp& aTime) {}
static inline void profiler_set_frame_number(int frameNumber) {}
// Get the profile encoded as a JSON string.
static inline mozilla::UniquePtr<char[]> profiler_get_profile(float aSinceTime = 0) {
static inline mozilla::UniquePtr<char[]> profiler_get_profile(double aSinceTime = 0) {
return nullptr;
}
// Get the profile encoded as a JSON object.
static inline JSObject* profiler_get_profile_jsobject(JSContext* aCx,
float aSinceTime = 0) {
double aSinceTime = 0) {
return nullptr;
}
// Get the profile encoded as a JSON object.
static inline void profiler_get_profile_jsobject_async(float aSinceTime = 0,
static inline void profiler_get_profile_jsobject_async(double aSinceTime = 0,
mozilla::dom::Promise* = 0) {}
// Get the profile and write it into a file

View File

@ -59,10 +59,10 @@ const double* mozilla_sampler_get_responsiveness();
void mozilla_sampler_save();
mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(float aSinceTime);
mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(double aSinceTime);
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime);
void mozilla_sampler_get_profile_data_async(float aSinceTime,
JSObject *mozilla_sampler_get_profile_data(JSContext* aCx, double aSinceTime);
void mozilla_sampler_get_profile_data_async(double aSinceTime,
mozilla::dom::Promise* aPromise);
// Make this function easily callable from a debugger in a build without

View File

@ -144,19 +144,19 @@ void profiler_set_frame_number(int frameNumber)
}
static inline
mozilla::UniquePtr<char[]> profiler_get_profile(float aSinceTime = 0)
mozilla::UniquePtr<char[]> profiler_get_profile(double aSinceTime = 0)
{
return mozilla_sampler_get_profile(aSinceTime);
}
static inline
JSObject* profiler_get_profile_jsobject(JSContext* aCx, float aSinceTime = 0)
JSObject* profiler_get_profile_jsobject(JSContext* aCx, double aSinceTime = 0)
{
return mozilla_sampler_get_profile_data(aCx, aSinceTime);
}
static inline
void profiler_get_profile_jsobject_async(float aSinceTime = 0,
void profiler_get_profile_jsobject_async(double aSinceTime = 0,
mozilla::dom::Promise* aPromise = 0)
{
mozilla_sampler_get_profile_data_async(aSinceTime, aPromise);

View File

@ -53,8 +53,8 @@ ProfileEntry::ProfileEntry(char aTagName, void *aTagPtr)
, mTagName(aTagName)
{ }
ProfileEntry::ProfileEntry(char aTagName, float aTagFloat)
: mTagFloat(aTagFloat)
ProfileEntry::ProfileEntry(char aTagName, double aTagDouble)
: mTagDouble(aTagDouble)
, mTagName(aTagName)
{ }
@ -563,12 +563,12 @@ void UniqueStacks::StreamFrame(const OnStackFrameKey& aFrame)
struct ProfileSample
{
uint32_t mStack;
Maybe<float> mTime;
Maybe<float> mResponsiveness;
Maybe<float> mRSS;
Maybe<float> mUSS;
Maybe<double> mTime;
Maybe<double> mResponsiveness;
Maybe<double> mRSS;
Maybe<double> mUSS;
Maybe<int> mFrameNumber;
Maybe<float> mPower;
Maybe<double> mPower;
};
static void WriteSample(SpliceableJSONWriter& aWriter, ProfileSample& aSample)
@ -632,13 +632,13 @@ static void WriteSample(SpliceableJSONWriter& aWriter, ProfileSample& aSample)
}
void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
float aSinceTime, JSRuntime* aRuntime,
double aSinceTime, JSRuntime* aRuntime,
UniqueStacks& aUniqueStacks)
{
Maybe<ProfileSample> sample;
int readPos = mReadPos;
int currentThreadID = -1;
Maybe<float> currentTime;
Maybe<double> currentTime;
UniquePtr<char[]> tagBuff = MakeUnique<char[]>(DYNAMIC_MAX_STRING);
while (readPos != mWritePos) {
@ -650,7 +650,7 @@ void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThre
if (readAheadPos != mWritePos) {
ProfileEntry readAheadEntry = mEntries[readAheadPos];
if (readAheadEntry.mTagName == 't') {
currentTime = Some(readAheadEntry.mTagFloat);
currentTime = Some(readAheadEntry.mTagDouble);
}
}
}
@ -658,22 +658,22 @@ void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThre
switch (entry.mTagName) {
case 'r':
if (sample.isSome()) {
sample->mResponsiveness = Some(entry.mTagFloat);
sample->mResponsiveness = Some(entry.mTagDouble);
}
break;
case 'p':
if (sample.isSome()) {
sample->mPower = Some(entry.mTagFloat);
sample->mPower = Some(entry.mTagDouble);
}
break;
case 'R':
if (sample.isSome()) {
sample->mRSS = Some(entry.mTagFloat);
sample->mRSS = Some(entry.mTagDouble);
}
break;
case 'U':
if (sample.isSome()) {
sample->mUSS = Some(entry.mTagFloat);
sample->mUSS = Some(entry.mTagDouble);
}
break;
case 'f':
@ -774,7 +774,7 @@ void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThre
}
void ProfileBuffer::StreamMarkersToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
float aSinceTime, UniqueStacks& aUniqueStacks)
double aSinceTime, UniqueStacks& aUniqueStacks)
{
int readPos = mReadPos;
int currentThreadID = -1;
@ -829,7 +829,7 @@ void ProfileBuffer::DuplicateLastSample(int aThreadId)
return;
case 't':
// Copy with new time
addTag(ProfileEntry('t', static_cast<float>((mozilla::TimeStamp::Now() - sStartTime).ToMilliseconds())));
addTag(ProfileEntry('t', (mozilla::TimeStamp::Now() - sStartTime).ToMilliseconds()));
break;
case 'm':
// Don't copy markers
@ -887,7 +887,7 @@ void ThreadProfile::addStoredMarker(ProfilerMarker *aStoredMarker) {
mBuffer->addStoredMarker(aStoredMarker);
}
void ThreadProfile::StreamJSON(SpliceableJSONWriter& aWriter, float aSinceTime)
void ThreadProfile::StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime)
{
// mUniqueStacks may already be emplaced from FlushSamplesAndMarkers.
if (!mUniqueStacks.isSome()) {
@ -944,7 +944,7 @@ void ThreadProfile::StreamJSON(SpliceableJSONWriter& aWriter, float aSinceTime)
mUniqueStacks.reset();
}
void ThreadProfile::StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, float aSinceTime,
void ThreadProfile::StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, double aSinceTime,
UniqueStacks& aUniqueStacks)
{
// Thread meta data

View File

@ -39,7 +39,7 @@ public:
ProfileEntry(char aTagName, const char *aTagData);
ProfileEntry(char aTagName, void *aTagPtr);
ProfileEntry(char aTagName, ProfilerMarker *aTagMarker);
ProfileEntry(char aTagName, float aTagFloat);
ProfileEntry(char aTagName, double aTagDouble);
ProfileEntry(char aTagName, uintptr_t aTagOffset);
ProfileEntry(char aTagName, Address aTagAddress);
ProfileEntry(char aTagName, int aTagLine);
@ -67,7 +67,7 @@ private:
char mTagChars[sizeof(void*)];
void* mTagPtr;
ProfilerMarker* mTagMarker;
float mTagFloat;
double mTagDouble;
Address mTagAddress;
uintptr_t mTagOffset;
int mTagInt;
@ -229,9 +229,9 @@ public:
explicit ProfileBuffer(int aEntrySize);
void addTag(const ProfileEntry& aTag);
void StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId, float aSinceTime,
void StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId, double aSinceTime,
JSRuntime* rt, UniqueStacks& aUniqueStacks);
void StreamMarkersToJSON(SpliceableJSONWriter& aWriter, int aThreadId, float aSinceTime,
void StreamMarkersToJSON(SpliceableJSONWriter& aWriter, int aThreadId, double aSinceTime,
UniqueStacks& aUniqueStacks);
void DuplicateLastSample(int aThreadId);
@ -376,7 +376,7 @@ public:
void addStoredMarker(ProfilerMarker *aStoredMarker);
PseudoStack* GetPseudoStack();
mozilla::Mutex* GetMutex();
void StreamJSON(SpliceableJSONWriter& aWriter, float aSinceTime = 0);
void StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime = 0);
/**
* Call this method when the JS entries inside the buffer are about to
@ -409,7 +409,7 @@ public:
}
protected:
void StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, float aSinceTime,
void StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, double aSinceTime,
UniqueStacks& aUniqueStacks);
private:

View File

@ -15,7 +15,7 @@ namespace mozilla {
NS_IMPL_ISUPPORTS0(ProfileGatherer)
ProfileGatherer::ProfileGatherer(TableTicker* aTicker,
float aSinceTime,
double aSinceTime,
Promise* aPromise)
: mPromise(aPromise)
, mTicker(aTicker)

View File

@ -17,7 +17,7 @@ public:
NS_DECL_ISUPPORTS
ProfileGatherer(TableTicker* aTicker,
float aSinceTime,
double aSinceTime,
mozilla::dom::Promise* aPromise);
void WillGatherOOPProfile();
void GatheredOOPProfile();
@ -29,10 +29,10 @@ private:
nsRefPtr<mozilla::dom::Promise> mPromise;
TableTicker* mTicker;
float mSinceTime;
double mSinceTime;
uint32_t mPendingProfiles;
};
} // namespace mozilla
#endif
#endif

View File

@ -82,7 +82,7 @@ class ProfilerMarker {
public:
explicit ProfilerMarker(const char* aMarkerName,
ProfilerMarkerPayload* aPayload = nullptr,
float aTime = 0);
double aTime = 0);
~ProfilerMarker();
@ -98,13 +98,13 @@ public:
return mGenID + 2 <= aGenID;
}
float GetTime() const;
double GetTime() const;
private:
char* mMarkerName;
ProfilerMarkerPayload* mPayload;
ProfilerMarker* mNext;
float mTime;
double mTime;
uint32_t mGenID;
};
@ -235,7 +235,7 @@ public:
mSleepId++;
}
void addMarker(const char *aMarkerStr, ProfilerMarkerPayload *aPayload, float aTime)
void addMarker(const char* aMarkerStr, ProfilerMarkerPayload* aPayload, double aTime)
{
ProfilerMarker* marker = new ProfilerMarker(aMarkerStr, aPayload, aTime);
mPendingMarkers.insert(marker);

View File

@ -159,7 +159,8 @@ TableTicker::TableTicker(double aInterval, int aEntrySize,
mThreadNameFilters[i] = aThreadNameFilters[i];
}
sStartTime = mozilla::TimeStamp::Now();
bool ignore;
sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
{
mozilla::MutexAutoLock lock(*sRegisteredThreadsMutex);
@ -313,13 +314,13 @@ void TableTicker::StreamMetaJSCustomObject(SpliceableJSONWriter& aWriter)
}
}
void TableTicker::ToStreamAsJSON(std::ostream& stream, float aSinceTime)
void TableTicker::ToStreamAsJSON(std::ostream& stream, double aSinceTime)
{
SpliceableJSONWriter b(mozilla::MakeUnique<OStreamJSONWriteFunc>(stream));
StreamJSON(b, aSinceTime);
}
JSObject* TableTicker::ToJSObject(JSContext *aCx, float aSinceTime)
JSObject* TableTicker::ToJSObject(JSContext* aCx, double aSinceTime)
{
JS::RootedValue val(aCx);
{
@ -356,14 +357,14 @@ JSObject* TableTicker::ToJSObject(JSContext *aCx, float aSinceTime)
return &val.toObject();
}
UniquePtr<char[]> TableTicker::ToJSON(float aSinceTime)
UniquePtr<char[]> TableTicker::ToJSON(double aSinceTime)
{
SpliceableChunkedJSONWriter b;
StreamJSON(b, aSinceTime);
return b.WriteFunc()->CopyData();
}
void TableTicker::ToJSObjectAsync(float aSinceTime,
void TableTicker::ToJSObjectAsync(double aSinceTime,
Promise* aPromise)
{
if (NS_WARN_IF(mGatherer)) {
@ -451,7 +452,7 @@ void BuildJavaThreadJSObject(SpliceableJSONWriter& aWriter)
}
#endif
void TableTicker::StreamJSON(SpliceableJSONWriter& aWriter, float aSinceTime)
void TableTicker::StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime)
{
aWriter.Start(SpliceableJSONWriter::SingleLineStyle);
{
@ -1118,7 +1119,7 @@ void TableTicker::InplaceTick(TickSample* sample)
if (sample) {
mozilla::TimeDuration delta = sample->timestamp - sStartTime;
currThreadProfile.addTag(ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())));
currThreadProfile.addTag(ProfileEntry('t', delta.ToMilliseconds()));
}
PseudoStack* stack = currThreadProfile.GetPseudoStack();
@ -1147,23 +1148,23 @@ void TableTicker::InplaceTick(TickSample* sample)
if (sample && currThreadProfile.GetThreadResponsiveness()->HasData()) {
mozilla::TimeDuration delta = currThreadProfile.GetThreadResponsiveness()->GetUnresponsiveDuration(sample->timestamp);
currThreadProfile.addTag(ProfileEntry('r', static_cast<float>(delta.ToMilliseconds())));
currThreadProfile.addTag(ProfileEntry('r', delta.ToMilliseconds()));
}
// rssMemory is equal to 0 when we are not recording.
if (sample && sample->rssMemory != 0) {
currThreadProfile.addTag(ProfileEntry('R', static_cast<float>(sample->rssMemory)));
currThreadProfile.addTag(ProfileEntry('R', static_cast<double>(sample->rssMemory)));
}
// ussMemory is equal to 0 when we are not recording.
if (sample && sample->ussMemory != 0) {
currThreadProfile.addTag(ProfileEntry('U', static_cast<float>(sample->ussMemory)));
currThreadProfile.addTag(ProfileEntry('U', static_cast<double>(sample->ussMemory)));
}
#if defined(XP_WIN)
if (mProfilePower) {
mIntelPowerGadget->TakeSample();
currThreadProfile.addTag(ProfileEntry('p', static_cast<float>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
currThreadProfile.addTag(ProfileEntry('p', static_cast<double>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
}
#endif

View File

@ -97,10 +97,10 @@ class TableTicker: public Sampler {
return mPrimaryThreadProfile;
}
void ToStreamAsJSON(std::ostream& stream, float aSinceTime = 0);
virtual JSObject *ToJSObject(JSContext *aCx, float aSinceTime = 0);
mozilla::UniquePtr<char[]> ToJSON(float aSinceTime = 0);
virtual void ToJSObjectAsync(float aSinceTime = 0, mozilla::dom::Promise* aPromise = 0);
void ToStreamAsJSON(std::ostream& stream, double aSinceTime = 0);
virtual JSObject *ToJSObject(JSContext* aCx, double aSinceTime = 0);
mozilla::UniquePtr<char[]> ToJSON(double aSinceTime = 0);
virtual void ToJSObjectAsync(double aSinceTime = 0, mozilla::dom::Promise* aPromise = 0);
void StreamMetaJSCustomObject(SpliceableJSONWriter& aWriter);
void StreamTaskTracer(SpliceableJSONWriter& aWriter);
void FlushOnJSShutdown(JSRuntime* aRuntime);
@ -128,7 +128,7 @@ protected:
// Not implemented on platforms which do not support backtracing
void doNativeBacktrace(ThreadProfile &aProfile, TickSample* aSample);
void StreamJSON(SpliceableJSONWriter& aWriter, float aSinceTime);
void StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime);
// This represent the application's main thread (SAMPLER_INIT)
ThreadProfile* mPrimaryThreadProfile;

View File

@ -12,7 +12,7 @@ class nsCString;
[ref] native StringArrayRef(const nsTArray<nsCString>);
[scriptable, uuid(0f474ec5-b95c-45d9-a7c8-156da0e3fa25)]
[scriptable, uuid(921e1223-b1ea-4906-bb26-a846e6b6835b)]
interface nsIProfiler : nsISupports
{
void StartProfiler(in uint32_t aEntries, in double aInterval,
@ -29,17 +29,17 @@ interface nsIProfiler : nsISupports
* Returns the JSON string of the profile. If aSinceTime is passed, only
* report samples taken at >= aSinceTime.
*/
string GetProfile([optional] in float aSinceTime);
string GetProfile([optional] in double aSinceTime);
/*
* Returns a JS object of the profile. If aSinceTime is passed, only report
* samples taken at >= aSinceTime.
*/
[implicit_jscontext]
jsval getProfileData([optional] in float aSinceTime);
jsval getProfileData([optional] in double aSinceTime);
[implicit_jscontext]
nsISupports getProfileDataAsync([optional] in float aSinceTime);
nsISupports getProfileDataAsync([optional] in double aSinceTime);
boolean IsActive();
void GetFeatures(out uint32_t aCount, [retval, array, size_is(aCount)] out string aFeatures);
@ -48,10 +48,11 @@ interface nsIProfiler : nsISupports
out uint32_t aGeneration);
/**
* Returns the elapsed time, in milliseconds, since the last StartProfiler call.
* Returns 0 if there is no active sampler.
* Returns the elapsed time, in milliseconds, since the profiler's epoch.
* The epoch is guaranteed to be constant for the duration of the
* process, but is otherwise arbitrary.
*/
float getElapsedTime();
double getElapsedTime();
/**
* Returns a JSON string of an array of shared library objects.

View File

@ -121,7 +121,7 @@ nsProfiler::AddMarker(const char *aMarker)
}
NS_IMETHODIMP
nsProfiler::GetProfile(float aSinceTime, char **aProfile)
nsProfiler::GetProfile(double aSinceTime, char** aProfile)
{
mozilla::UniquePtr<char[]> profile = profiler_get_profile(aSinceTime);
if (profile) {
@ -205,7 +205,7 @@ nsProfiler::DumpProfileToFile(const char* aFilename)
}
NS_IMETHODIMP
nsProfiler::GetProfileData(float aSinceTime, JSContext* aCx,
nsProfiler::GetProfileData(double aSinceTime, JSContext* aCx,
JS::MutableHandle<JS::Value> aResult)
{
JS::RootedObject obj(aCx, profiler_get_profile_jsobject(aCx, aSinceTime));
@ -217,7 +217,7 @@ nsProfiler::GetProfileData(float aSinceTime, JSContext* aCx,
}
NS_IMETHODIMP
nsProfiler::GetProfileDataAsync(float aSinceTime, JSContext* aCx,
nsProfiler::GetProfileDataAsync(double aSinceTime, JSContext* aCx,
nsISupports** aPromise)
{
MOZ_ASSERT(NS_IsMainThread());
@ -245,9 +245,9 @@ nsProfiler::GetProfileDataAsync(float aSinceTime, JSContext* aCx,
}
NS_IMETHODIMP
nsProfiler::GetElapsedTime(float* aElapsedTime)
nsProfiler::GetElapsedTime(double* aElapsedTime)
{
*aElapsedTime = static_cast<float>(profiler_time());
*aElapsedTime = profiler_time();
return NS_OK;
}

View File

@ -14,6 +14,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/TimeStamp.h"
#include "PseudoStack.h"
#include "TableTicker.h"
#include "nsIObserverService.h"
@ -182,8 +183,8 @@ StackOwningThreadInfo::SetPendingDelete()
}
ProfilerMarker::ProfilerMarker(const char* aMarkerName,
ProfilerMarkerPayload* aPayload,
float aTime)
ProfilerMarkerPayload* aPayload,
double aTime)
: mMarkerName(strdup(aMarkerName))
, mPayload(aPayload)
, mTime(aTime)
@ -200,7 +201,7 @@ ProfilerMarker::SetGeneration(uint32_t aGenID) {
mGenID = aGenID;
}
float
double
ProfilerMarker::GetTime() const {
return mTime;
}
@ -466,6 +467,9 @@ void mozilla_sampler_init(void* stackTop)
LOG("Failed to init.");
return;
}
bool ignore;
sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
stack_key_initialized = true;
Sampler::Startup();
@ -561,7 +565,7 @@ void mozilla_sampler_save()
t->HandleSaveRequest();
}
mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(float aSinceTime)
mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(double aSinceTime)
{
TableTicker *t = tlsTicker.get();
if (!t) {
@ -571,7 +575,7 @@ mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(float aSinceTime)
return t->ToJSON(aSinceTime);
}
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime)
JSObject* mozilla_sampler_get_profile_data(JSContext* aCx, double aSinceTime)
{
TableTicker *t = tlsTicker.get();
if (!t) {
@ -581,7 +585,7 @@ JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime)
return t->ToJSObject(aCx, aSinceTime);
}
void mozilla_sampler_get_profile_data_async(float aSinceTime,
void mozilla_sampler_get_profile_data_async(double aSinceTime,
mozilla::dom::Promise* aPromise)
{
TableTicker *t = tlsTicker.get();
@ -968,9 +972,6 @@ void mozilla_sampler_sleep_end() {
double mozilla_sampler_time(const mozilla::TimeStamp& aTime)
{
if (!mozilla_sampler_is_active()) {
return 0.0;
}
mozilla::TimeDuration delta = aTime - sStartTime;
return delta.ToMilliseconds();
}
@ -1049,7 +1050,7 @@ void mozilla_sampler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPay
mozilla::TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) ?
aPayload->GetStartTime() : mozilla::TimeStamp::Now();
mozilla::TimeDuration delta = origin - sStartTime;
stack->addMarker(aMarker, payload.forget(), static_cast<float>(delta.ToMilliseconds()));
stack->addMarker(aMarker, payload.forget(), delta.ToMilliseconds());
}
// END externally visible functions

View File

@ -22,10 +22,10 @@ TEST(ThreadProfile, InsertOneTag) {
Thread::tid_t tid = 1000;
ThreadInfo info("testThread", tid, true, stack, nullptr);
nsRefPtr<ProfileBuffer> pb = new ProfileBuffer(10);
pb->addTag(ProfileEntry('t', 123.1f));
pb->addTag(ProfileEntry('t', 123.1));
ASSERT_TRUE(pb->mEntries != nullptr);
ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagName == 't');
ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagFloat == 123.1f);
ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagDouble == 123.1);
}
// See if we can insert some tags

View File

@ -876,6 +876,9 @@ Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(JNIEnv* jenv, jclass
NS_EXPORT jdouble JNICALL
Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime(JNIEnv *jenv, jclass jc)
{
if (!profiler_is_active()) {
return 0.0;
}
return profiler_time();
}