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

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

Issue 13454002: Allow recording individual samples in addition to the aggregated CPU profiles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 7 years, 9 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-cpu-profiler.cc ('k') | no next file » | 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 22b4e059a246993aa2bae921e16ed758377c23ee..884ca834fb263ef43de88f2473671da406ad4b3e 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -85,7 +85,8 @@ TEST(TokenEnumerator) {
TEST(ProfileNodeFindOrAddChild) {
- ProfileNode node(NULL, NULL);
+ ProfileTree tree;
+ ProfileNode node(&tree, NULL);
CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
@@ -113,7 +114,8 @@ TEST(ProfileNodeFindOrAddChild) {
TEST(ProfileNodeFindOrAddChildForSameFunction) {
const char* empty = "";
const char* aaa = "aaa";
- ProfileNode node(NULL, NULL);
+ ProfileTree tree;
+ ProfileNode node(&tree, NULL);
CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0,
TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
@@ -607,7 +609,7 @@ class TestSetup {
TEST(RecordTickSample) {
TestSetup test_setup;
CpuProfilesCollection profiles;
- profiles.StartProfiling("", 1);
+ profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
@@ -713,6 +715,88 @@ TEST(SampleRateCalculator) {
}
+static void CheckNodeIds(ProfileNode* node, int* expectedId) {
+ CHECK_EQ((*expectedId)++, node->id());
+ for (int i = 0; i < node->children()->length(); i++) {
+ CheckNodeIds(node->children()->at(i), expectedId);
+ }
+}
+
+TEST(SampleIds) {
+ TestSetup test_setup;
+ CpuProfilesCollection profiles;
+ profiles.StartProfiling("", 1, true);
+ ProfileGenerator generator(&profiles);
+ CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
+ CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
+ CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc");
+ generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
+ generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
+ generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
+
+ // We are building the following calls tree:
+ // -> aaa #3 - sample1
+ // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2
+ // -> ccc #6 -> aaa #7 - sample3
+ TickSample sample1;
+ sample1.pc = ToAddress(0x1600);
+ sample1.stack[0] = ToAddress(0x1510);
+ sample1.frames_count = 1;
+ generator.RecordTickSample(sample1);
+ TickSample sample2;
+ sample2.pc = ToAddress(0x1925);
+ sample2.stack[0] = ToAddress(0x1780);
+ sample2.stack[1] = ToAddress(0x10000); // non-existent.
+ sample2.stack[2] = ToAddress(0x1620);
+ sample2.frames_count = 3;
+ generator.RecordTickSample(sample2);
+ TickSample sample3;
+ sample3.pc = ToAddress(0x1510);
+ sample3.stack[0] = ToAddress(0x1910);
+ sample3.stack[1] = ToAddress(0x1610);
+ sample3.frames_count = 2;
+ generator.RecordTickSample(sample3);
+
+ CpuProfile* profile =
+ profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
+ int nodeId = 1;
+ CheckNodeIds(profile->top_down()->root(), &nodeId);
+ CHECK_EQ(7, nodeId - 1);
+
+ CHECK_EQ(3, profile->samples_count());
+ int expected_id[] = {3, 5, 7};
+ for (int i = 0; i < 3; i++) {
+ CHECK_EQ(expected_id[i], profile->sample(i)->id());
+ }
+}
+
+
+TEST(NoSamples) {
+ TestSetup test_setup;
+ CpuProfilesCollection profiles;
+ profiles.StartProfiling("", 1, false);
+ ProfileGenerator generator(&profiles);
+ CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
+ generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
+
+ // We are building the following calls tree:
+ // (root)#1 -> aaa #2 -> aaa #3 - sample1
+ TickSample sample1;
+ sample1.pc = ToAddress(0x1600);
+ sample1.stack[0] = ToAddress(0x1510);
+ sample1.frames_count = 1;
+ generator.RecordTickSample(sample1);
+
+ CpuProfile* profile =
+ profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
+ int nodeId = 1;
+ CheckNodeIds(profile->top_down()->root(), &nodeId);
+ CHECK_EQ(3, nodeId - 1);
+
+ CHECK_EQ(0, profile->samples_count());
+}
+
+
// --- P r o f i l e r E x t e n s i o n ---
class ProfilerExtension : public v8::Extension {
@@ -838,11 +922,12 @@ TEST(Issue51919) {
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
i::Vector<char> title = i::Vector<char>::New(16);
i::OS::SNPrintF(title, "%d", i);
- CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0.
+ // UID must be > 0.
+ CHECK(collection.StartProfiling(title.start(), i + 1, false));
titles[i] = title.start();
}
CHECK(!collection.StartProfiling(
- "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1));
+ "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
i::DeleteArray(titles[i]);
}
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698