Two simple profiler changes: 1) log sampling rate, 2) check current state...

Two simple profiler changes: 1) log sampling rate, 2) check current state before pausing & resuming.

Review URL: http://codereview.chromium.org/113961


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2073 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 795ba991
......@@ -256,7 +256,7 @@ void Profiler::Engage() {
// Register to get ticks.
Logger::ticker_->SetProfiler(this);
LOG(UncheckedStringEvent("profiler", "begin"));
Logger::ProfilerBeginEvent();
}
......@@ -302,6 +302,14 @@ bool Logger::IsEnabled() {
return Log::IsEnabled();
}
void Logger::ProfilerBeginEvent() {
if (!Log::IsEnabled()) return;
LogMessageBuilder msg;
msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs);
msg.WriteToLogFile();
}
#endif // ENABLE_LOGGING_AND_PROFILING
......@@ -809,6 +817,9 @@ bool Logger::IsProfilerPaused() {
void Logger::PauseProfiler() {
if (profiler_->paused()) {
return;
}
profiler_->pause();
if (FLAG_prof_lazy) {
if (!FLAG_sliding_state_window) ticker_->Stop();
......@@ -820,7 +831,9 @@ void Logger::PauseProfiler() {
void Logger::ResumeProfiler() {
if (!Log::IsEnabled()) return;
if (!profiler_->paused() || !Log::IsEnabled()) {
return;
}
if (FLAG_prof_lazy) {
LOG(UncheckedStringEvent("profiler", "resume"));
FLAG_log_code = true;
......@@ -992,7 +1005,8 @@ bool Logger::Setup() {
// as log is initialized early with V8, we can assume that JS execution
// frames can never reach this point on stack
int stack_var;
ticker_ = new Ticker(1, reinterpret_cast<uintptr_t>(&stack_var));
ticker_ = new Ticker(
kSamplingIntervalMs, reinterpret_cast<uintptr_t>(&stack_var));
if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
sliding_state_window_ = new SlidingStateWindow();
......
......@@ -220,6 +220,12 @@ class Logger {
private:
// Profiler's sampling interval (in milliseconds).
static const int kSamplingIntervalMs = 1;
// Emits the profiler's first message.
static void ProfilerBeginEvent();
// Emits the source code of a regexp. Used by regexp events.
static void LogRegExpSource(Handle<JSRegExp> regexp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment