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

Side by Side Diff: src/sampler.cc

Issue 1118533003: Make CPU profiler do not hog 100% of CPU. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: still uploading Created 5 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-test.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/sampler.h" 5 #include "src/sampler.h"
6 6
7 #if V8_OS_POSIX && !V8_OS_CYGWIN 7 #if V8_OS_POSIX && !V8_OS_CYGWIN
8 8
9 #define USE_SIGNALS 9 #define USE_SIGNALS
10 10
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 base::LockGuard<base::Mutex> lock_guard(mutex_); 551 base::LockGuard<base::Mutex> lock_guard(mutex_);
552 if (active_samplers_.is_empty()) break; 552 if (active_samplers_.is_empty()) break;
553 // When CPU profiling is enabled both JavaScript and C++ code is 553 // When CPU profiling is enabled both JavaScript and C++ code is
554 // profiled. We must not suspend. 554 // profiled. We must not suspend.
555 for (int i = 0; i < active_samplers_.length(); ++i) { 555 for (int i = 0; i < active_samplers_.length(); ++i) {
556 Sampler* sampler = active_samplers_.at(i); 556 Sampler* sampler = active_samplers_.at(i);
557 if (!sampler->IsProfiling()) continue; 557 if (!sampler->IsProfiling()) continue;
558 sampler->DoSample(); 558 sampler->DoSample();
559 } 559 }
560 } 560 }
561 base::OS::Sleep(interval_); 561 base::OS::Sleep(base::TimeDelta::FromMilliseconds(interval_));
562 } 562 }
563 } 563 }
564 564
565 private: 565 private:
566 // Protects the process wide state below. 566 // Protects the process wide state below.
567 static base::Mutex* mutex_; 567 static base::Mutex* mutex_;
568 static SamplerThread* instance_; 568 static SamplerThread* instance_;
569 569
570 const int interval_; 570 const int interval_;
571 List<Sampler*> active_samplers_; 571 List<Sampler*> active_samplers_;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 #endif // USE_SIMULATOR 769 #endif // USE_SIMULATOR
770 SampleStack(state); 770 SampleStack(state);
771 } 771 }
772 ResumeThread(profiled_thread); 772 ResumeThread(profiled_thread);
773 } 773 }
774 774
775 #endif // USE_SIGNALS 775 #endif // USE_SIGNALS
776 776
777 777
778 } } // namespace v8::internal 778 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-test.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698