Commit 487a6193 authored by loislo@chromium.org's avatar loislo@chromium.org

Improve test-cpu-profiler.cc tests stability

The tests sometimes fail on bots as they don't have time to collect enough samples. This change makes them use counter of samples taken when v8 is either in JS or EXTERNAL state and repeat sampling until desired threshold is reached.

BUG=v8:2628
R=loislo@chromium.org, yangguo@chromium.org

Review URL: https://codereview.chromium.org/18418004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15592 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent daacd583
......@@ -658,7 +658,8 @@ Sampler::Sampler(Isolate* isolate, int interval)
interval_(interval),
profiling_(false),
active_(false),
samples_taken_(0) {
is_counting_samples_(false),
js_and_external_sample_count_(0) {
data_ = new PlatformData;
}
......@@ -688,7 +689,11 @@ void Sampler::SampleStack(const RegisterState& state) {
TickSample sample_obj;
if (sample == NULL) sample = &sample_obj;
sample->Init(isolate_, state);
if (++samples_taken_ < 0) samples_taken_ = 0;
if (is_counting_samples_) {
if (sample->state == JS || sample->state == EXTERNAL) {
++js_and_external_sample_count_;
}
}
Tick(sample);
}
......
......@@ -103,8 +103,13 @@ class Sampler {
bool IsActive() const { return NoBarrier_Load(&active_); }
// Used in tests to make sure that stack sampling is performed.
int samples_taken() const { return samples_taken_; }
void ResetSamplesTaken() { samples_taken_ = 0; }
unsigned js_and_external_sample_count() const {
return js_and_external_sample_count_;
}
void StartCountingSamples() {
is_counting_samples_ = true;
js_and_external_sample_count_ = 0;
}
class PlatformData;
PlatformData* platform_data() const { return data_; }
......@@ -122,7 +127,9 @@ class Sampler {
Atomic32 profiling_;
Atomic32 active_;
PlatformData* data_; // Platform specific data.
int samples_taken_; // Counts stack samples taken.
bool is_counting_samples_;
// Counts stack samples taken in JS VM state.
unsigned js_and_external_sample_count_;
DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
};
......
This diff is collapsed.
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