PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title) { v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); if (!profiler) return 0; v8::HandleScope handleScope(isolate); v8::Handle<v8::Value> securityToken; if (state) securityToken = state->context()->GetSecurityToken(); const v8::CpuProfile* profile = profiler->StopCpuProfiling(v8String(title, isolate), securityToken); if (!profile) return 0; String profileTitle = toWebCoreString(profile->GetTitle()); double idleTime = 0.0; ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProfileNameIdleTimeMap(); ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->find(profileTitle); if (profileIdleTime != profileNameIdleTimeMap->end()) { idleTime = profileIdleTime->value * 1000.0; profileNameIdleTimeMap->remove(profileIdleTime); } return ScriptProfile::create(profile, idleTime); }
PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title) { v8::HandleScope hs; const v8::CpuProfile* profile = state ? v8::CpuProfiler::StopProfiling(deprecatedV8String(title), state->context()->GetSecurityToken()) : v8::CpuProfiler::StopProfiling(deprecatedV8String(title)); double idleTime = 0.0; ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProfileNameIdleTimeMap(); ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->find(title); if (profileIdleTime != profileNameIdleTimeMap->end()) { idleTime = profileIdleTime->value * 1000.0; profileNameIdleTimeMap->remove(profileIdleTime); } return profile ? ScriptProfile::create(profile, idleTime) : 0; }
PassRefPtr<ScriptProfile> ScriptProfiler::stop(const String& title) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); if (!profiler) return nullptr; v8::HandleScope handleScope(isolate); v8::CpuProfile* profile = profiler->StopProfiling(v8String(isolate, title)); if (!profile) return nullptr; String profileTitle = toCoreString(profile->GetTitle()); double idleTime = 0.0; ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProfileNameIdleTimeMap(); ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->find(profileTitle); if (profileIdleTime != profileNameIdleTimeMap->end()) { idleTime = profileIdleTime->value * 1000.0; profileNameIdleTimeMap->remove(profileIdleTime); } return ScriptProfile::create(profile, idleTime); }