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

Unified Diff: test/cctest/test-profile-generator.cc

Issue 21173004: Version 3.20.11.1 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | « test/cctest/test-log.cc ('k') | test/mjsunit/array-literal-transitions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-profile-generator.cc
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index f56275c1beef1e0b6ec8efcc5d9d5207bf7d0296..7b8278ba660d4d490a026af108308b1c756e3043 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -41,6 +41,7 @@ using i::CpuProfilesCollection;
using i::ProfileNode;
using i::ProfileTree;
using i::ProfileGenerator;
+using i::SampleRateCalculator;
using i::TickSample;
using i::Vector;
@@ -484,7 +485,7 @@ TEST(RecordTickSample) {
sample3.frames_count = 2;
generator.RecordTickSample(sample3);
- CpuProfile* profile = profiles.StopProfiling("");
+ CpuProfile* profile = profiles.StopProfiling("", 1);
CHECK_NE(NULL, profile);
ProfileTreeTestHelper top_down_test_helper(profile->top_down());
CHECK_EQ(NULL, top_down_test_helper.Walk(entry2));
@@ -504,6 +505,56 @@ TEST(RecordTickSample) {
}
+TEST(SampleRateCalculator) {
+ const double kSamplingIntervalMs = i::Logger::kSamplingIntervalMs;
+
+ // Verify that ticking exactly in query intervals results in the
+ // initial sampling interval.
+ double time = 0.0;
+ SampleRateCalculator calc1;
+ CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms());
+ calc1.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs;
+ calc1.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs;
+ calc1.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs;
+ calc1.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms());
+
+ SampleRateCalculator calc2;
+ time = 0.0;
+ CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms());
+ calc2.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.5;
+ calc2.UpdateMeasurements(time);
+ // (1.0 + 2.0) / 2
+ CHECK_EQ(kSamplingIntervalMs * 1.5, calc2.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.75;
+ calc2.UpdateMeasurements(time);
+ // (1.0 + 2.0 + 2.0) / 3
+ CHECK_EQ(kSamplingIntervalMs * 5.0, floor(calc2.ticks_per_ms() * 3.0 + 0.5));
+
+ SampleRateCalculator calc3;
+ time = 0.0;
+ CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms());
+ calc3.UpdateMeasurements(time);
+ CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs * 2;
+ calc3.UpdateMeasurements(time);
+ // (1.0 + 0.5) / 2
+ CHECK_EQ(kSamplingIntervalMs * 0.75, calc3.ticks_per_ms());
+ time += SampleRateCalculator::kWallTimeQueryIntervalMs * 1.5;
+ calc3.UpdateMeasurements(time);
+ // (1.0 + 0.5 + 0.5) / 3
+ CHECK_EQ(kSamplingIntervalMs * 2.0, floor(calc3.ticks_per_ms() * 3.0 + 0.5));
+}
+
+
static void CheckNodeIds(ProfileNode* node, int* expectedId) {
CHECK_EQ((*expectedId)++, node->id());
for (int i = 0; i < node->children()->length(); i++) {
@@ -547,7 +598,7 @@ TEST(SampleIds) {
sample3.frames_count = 2;
generator.RecordTickSample(sample3);
- CpuProfile* profile = profiles.StopProfiling("");
+ CpuProfile* profile = profiles.StopProfiling("", 1);
int nodeId = 1;
CheckNodeIds(profile->top_down()->root(), &nodeId);
CHECK_EQ(7, nodeId - 1);
@@ -576,7 +627,7 @@ TEST(NoSamples) {
sample1.frames_count = 1;
generator.RecordTickSample(sample1);
- CpuProfile* profile = profiles.StopProfiling("");
+ CpuProfile* profile = profiles.StopProfiling("", 1);
int nodeId = 1;
CheckNodeIds(profile->top_down()->root(), &nodeId);
CHECK_EQ(3, nodeId - 1);
« no previous file with comments | « test/cctest/test-log.cc ('k') | test/mjsunit/array-literal-transitions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698