Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: Source/core/inspector/InspectorProfilerAgent.cpp

Issue 23690005: Allow configuring CPU profiler sampling interval (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 #include "core/inspector/InstrumentingAgents.h" 40 #include "core/inspector/InstrumentingAgents.h"
41 #include "core/inspector/ScriptCallStack.h" 41 #include "core/inspector/ScriptCallStack.h"
42 #include "core/inspector/ScriptProfile.h" 42 #include "core/inspector/ScriptProfile.h"
43 #include "core/page/ConsoleTypes.h" 43 #include "core/page/ConsoleTypes.h"
44 #include "wtf/CurrentTime.h" 44 #include "wtf/CurrentTime.h"
45 #include "wtf/text/StringConcatenate.h" 45 #include "wtf/text/StringConcatenate.h"
46 46
47 namespace WebCore { 47 namespace WebCore {
48 48
49 namespace ProfilerAgentState { 49 namespace ProfilerAgentState {
50 static const char samplingInterval[] = "samplingInterval";
50 static const char userInitiatedProfiling[] = "userInitiatedProfiling"; 51 static const char userInitiatedProfiling[] = "userInitiatedProfiling";
51 static const char profilerEnabled[] = "profilerEnabled"; 52 static const char profilerEnabled[] = "profilerEnabled";
52 static const char profileHeadersRequested[] = "profileHeadersRequested"; 53 static const char profileHeadersRequested[] = "profileHeadersRequested";
53 } 54 }
54 55
55 static const char* const userInitiatedProfileName = "org.webkit.profiles.user-in itiated"; 56 static const char* const userInitiatedProfileName = "org.webkit.profiles.user-in itiated";
56 static const char* const CPUProfileType = "CPU"; 57 static const char* const CPUProfileType = "CPU";
57 58
58 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA gents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InspectorCompos iteState* inspectorState, InjectedScriptManager* injectedScriptManager) 59 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA gents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InspectorCompos iteState* inspectorState, InjectedScriptManager* injectedScriptManager)
59 { 60 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 m_instrumentingAgents->setInspectorProfilerAgent(0); 128 m_instrumentingAgents->setInspectorProfilerAgent(0);
128 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); 129 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
129 m_state->setBoolean(ProfilerAgentState::profileHeadersRequested, false); 130 m_state->setBoolean(ProfilerAgentState::profileHeadersRequested, false);
130 } 131 }
131 132
132 bool InspectorProfilerAgent::enabled() 133 bool InspectorProfilerAgent::enabled()
133 { 134 {
134 return m_state->getBoolean(ProfilerAgentState::profilerEnabled); 135 return m_state->getBoolean(ProfilerAgentState::profilerEnabled);
135 } 136 }
136 137
138 void InspectorProfilerAgent::setSamplingInterval(ErrorString* error, int interva l)
139 {
140 if (m_recordingCPUProfile) {
141 *error = "Cannot change sampling interval when profiling.";
142 return;
143 }
144 m_state->setLong(ProfilerAgentState::samplingInterval, interval);
145 ScriptProfiler::setSamplingInterval(interval);
146 }
147
137 String InspectorProfilerAgent::getCurrentUserInitiatedProfileName(bool increment ProfileNumber) 148 String InspectorProfilerAgent::getCurrentUserInitiatedProfileName(bool increment ProfileNumber)
138 { 149 {
139 if (incrementProfileNumber) 150 if (incrementProfileNumber)
140 m_currentUserInitiatedProfileNumber = m_nextUserInitiatedProfileNumber++ ; 151 m_currentUserInitiatedProfileNumber = m_nextUserInitiatedProfileNumber++ ;
141 152
142 return String(userInitiatedProfileName) + "." + String::number(m_currentUser InitiatedProfileNumber); 153 return String(userInitiatedProfileName) + "." + String::number(m_currentUser InitiatedProfileNumber);
143 } 154 }
144 155
145 void InspectorProfilerAgent::getProfileHeaders(ErrorString*, RefPtr<TypeBuilder: :Array<TypeBuilder::Profiler::ProfileHeader> >& headers) 156 void InspectorProfilerAgent::getProfileHeaders(ErrorString*, RefPtr<TypeBuilder: :Array<TypeBuilder::Profiler::ProfileHeader> >& headers)
146 { 157 {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 { 216 {
206 m_frontend = 0; 217 m_frontend = 0;
207 stop(); 218 stop();
208 ErrorString error; 219 ErrorString error;
209 disable(&error); 220 disable(&error);
210 } 221 }
211 222
212 void InspectorProfilerAgent::restore() 223 void InspectorProfilerAgent::restore()
213 { 224 {
214 resetFrontendProfiles(); 225 resetFrontendProfiles();
226 if (long interval = m_state->getLong(ProfilerAgentState::samplingInterval, i nterval))
227 ScriptProfiler::setSamplingInterval(interval);
215 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling)) 228 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling))
216 start(); 229 start();
217 } 230 }
218 231
219 void InspectorProfilerAgent::start(ErrorString*) 232 void InspectorProfilerAgent::start(ErrorString*)
220 { 233 {
221 if (m_recordingCPUProfile) 234 if (m_recordingCPUProfile)
222 return; 235 return;
223 if (!enabled()) { 236 if (!enabled()) {
224 ErrorString error; 237 ErrorString error;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 idleStarted(); 315 idleStarted();
303 } 316 }
304 317
305 void InspectorProfilerAgent::didLeaveNestedRunLoop() 318 void InspectorProfilerAgent::didLeaveNestedRunLoop()
306 { 319 {
307 idleFinished(); 320 idleFinished();
308 } 321 }
309 322
310 } // namespace WebCore 323 } // namespace WebCore
311 324
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorProfilerAgent.h ('k') | Source/devtools/front_end/ProfilesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698