| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 typedef HashMap<String, double> ProfileNameIdleTimeMap; | 52 typedef HashMap<String, double> ProfileNameIdleTimeMap; |
| 53 | 53 |
| 54 void ScriptProfiler::start(ScriptState* state, const String& title) | 54 void ScriptProfiler::start(ScriptState* state, const String& title) |
| 55 { | 55 { |
| 56 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); | 56 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); |
| 57 if (profileNameIdleTimeMap->contains(title)) | 57 if (profileNameIdleTimeMap->contains(title)) |
| 58 return; | 58 return; |
| 59 profileNameIdleTimeMap->add(title, 0); | 59 profileNameIdleTimeMap->add(title, 0); |
| 60 | 60 |
| 61 v8::HandleScope hs; | 61 v8::HandleScope hs; |
| 62 v8::CpuProfiler::StartProfiling(v8String(title, state->isolate())); | 62 v8::CpuProfiler::StartProfiling(deprecatedV8String(title)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ScriptProfiler::startForPage(Page*, const String& title) | 65 void ScriptProfiler::startForPage(Page*, const String& title) |
| 66 { | 66 { |
| 67 return start(0, title); | 67 return start(0, title); |
| 68 } | 68 } |
| 69 | 69 |
| 70 #if ENABLE(WORKERS) | 70 #if ENABLE(WORKERS) |
| 71 void ScriptProfiler::startForWorkerContext(WorkerContext*, const String& title) | 71 void ScriptProfiler::startForWorkerContext(WorkerContext*, const String& title) |
| 72 { | 72 { |
| 73 return start(0, title); | 73 return start(0, title); |
| 74 } | 74 } |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String&
title) | 77 PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String&
title) |
| 78 { | 78 { |
| 79 v8::HandleScope hs; | 79 v8::HandleScope hs; |
| 80 const v8::CpuProfile* profile = state ? | 80 const v8::CpuProfile* profile = state ? |
| 81 v8::CpuProfiler::StopProfiling(v8String(title, state->isolate()), state-
>context()->GetSecurityToken()) : | 81 v8::CpuProfiler::StopProfiling(deprecatedV8String(title), state->context
()->GetSecurityToken()) : |
| 82 v8::CpuProfiler::StopProfiling(v8String(title, state->isolate())); | 82 v8::CpuProfiler::StopProfiling(deprecatedV8String(title)); |
| 83 if (!profile) | 83 if (!profile) |
| 84 return 0; | 84 return 0; |
| 85 | 85 |
| 86 String profileTitle = toWebCoreString(profile->GetTitle()); | 86 String profileTitle = toWebCoreString(profile->GetTitle()); |
| 87 double idleTime = 0.0; | 87 double idleTime = 0.0; |
| 88 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); | 88 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); |
| 89 ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->f
ind(profileTitle); | 89 ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->f
ind(profileTitle); |
| 90 if (profileIdleTime != profileNameIdleTimeMap->end()) { | 90 if (profileIdleTime != profileNameIdleTimeMap->end()) { |
| 91 idleTime = profileIdleTime->value * 1000.0; | 91 idleTime = profileIdleTime->value * 1000.0; |
| 92 profileNameIdleTimeMap->remove(profileIdleTime); | 92 profileNameIdleTimeMap->remove(profileIdleTime); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap() | 287 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap() |
| 288 { | 288 { |
| 289 AtomicallyInitializedStatic(WTF::ThreadSpecific<ProfileNameIdleTimeMap>*, ma
p = new WTF::ThreadSpecific<ProfileNameIdleTimeMap>); | 289 AtomicallyInitializedStatic(WTF::ThreadSpecific<ProfileNameIdleTimeMap>*, ma
p = new WTF::ThreadSpecific<ProfileNameIdleTimeMap>); |
| 290 return *map; | 290 return *map; |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace WebCore | 293 } // namespace WebCore |
| 294 | 294 |
| 295 #endif // ENABLE(INSPECTOR) | 295 #endif // ENABLE(INSPECTOR) |
| OLD | NEW |