Skip to content

Commit

Permalink
Bug 1145824 - Add getElapsedTime to nsIProfiler. (r=mstange)
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Apr 25, 2015
1 parent 3eabbee commit fd79d51
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tools/profiler/nsIProfiler.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class nsCString;

[ref] native StringArrayRef(const nsTArray<nsCString>);

[scriptable, uuid(edd65f3f-c2a2-4217-a2e2-40347ba4a2b3)]
[scriptable, uuid(9c3c0534-ef4b-4a6e-a1a6-4522d4824ac8)]
interface nsIProfiler : nsISupports
{
void StartProfiler(in uint32_t aEntries, in double aInterval,
Expand All @@ -34,6 +34,12 @@ interface nsIProfiler : nsISupports
void GetBufferInfo(out uint32_t aCurrentPosition, out uint32_t aTotalSize,
out uint32_t aGeneration);

/**
* Returns the elapsed time, in milliseconds, since the last StartProfiler call.
* Returns 0 if there is no active sampler.
*/
float getElapsedTime();

/**
* Returns a JSON string of an array of shared library objects.
* Every object has three properties: start, end, and name.
Expand Down
12 changes: 10 additions & 2 deletions tools/profiler/nsProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ nsProfiler::DumpProfileToFile(const char* aFilename)
return NS_OK;
}

NS_IMETHODIMP nsProfiler::GetProfileData(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult)
NS_IMETHODIMP
nsProfiler::GetProfileData(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult)
{
JS::RootedObject obj(aCx, profiler_get_profile_jsobject(aCx));
if (!obj) {
Expand All @@ -212,6 +213,13 @@ NS_IMETHODIMP nsProfiler::GetProfileData(JSContext* aCx,
return NS_OK;
}

NS_IMETHODIMP
nsProfiler::GetElapsedTime(float* aElapsedTime)
{
*aElapsedTime = static_cast<float>(profiler_time());
return NS_OK;
}

NS_IMETHODIMP
nsProfiler::IsActive(bool *aIsActive)
{
Expand Down

0 comments on commit fd79d51

Please sign in to comment.