Bug 1145824 - Add getElapsedTime to nsIProfiler. (r=mstange)

This commit is contained in:
Shu-yu Guo 2015-04-24 17:30:58 -07:00
parent e4e35eed6d
commit c2c97e5ba3
2 changed files with 17 additions and 3 deletions

View File

@ -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,
@ -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.

View File

@ -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) {
@ -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)
{