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

Unified Diff: src/log.cc

Issue 113961: Two simple profiler changes: 1) log sampling rate, 2) check current state before pausing & resuming. (Closed)
Patch Set: Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 6b0f6a9253324e90245eb104e97e35d661674160..c66a422fde35dfdfbd215ab604723c979d6cccc1 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -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();
« no previous file with comments | « src/log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698