OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include "v8.h" | 7 #include "v8.h" |
8 #include "profile-generator-inl.h" | 8 #include "profile-generator-inl.h" |
9 #include "cctest.h" | 9 #include "cctest.h" |
10 #include "../include/v8-profiler.h" | 10 #include "../include/v8-profiler.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); | 82 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); |
83 CHECK_NE(NULL, childNode3); | 83 CHECK_NE(NULL, childNode3); |
84 CHECK_NE(childNode1, childNode3); | 84 CHECK_NE(childNode1, childNode3); |
85 CHECK_NE(childNode2, childNode3); | 85 CHECK_NE(childNode2, childNode3); |
86 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 86 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
87 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 87 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
88 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); | 88 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); |
89 } | 89 } |
90 | 90 |
91 | 91 |
| 92 TEST(ProfileNodeFindOrAddChildForSameFunction) { |
| 93 ProfileNode node(NULL, NULL); |
| 94 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 95 TokenEnumerator::kNoSecurityToken); |
| 96 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
| 97 CHECK_NE(NULL, childNode1); |
| 98 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 99 // The same function again. |
| 100 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 101 TokenEnumerator::kNoSecurityToken); |
| 102 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); |
| 103 // Now with a different security token. |
| 104 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 105 TokenEnumerator::kNoSecurityToken + 1); |
| 106 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); |
| 107 } |
| 108 |
| 109 |
92 namespace { | 110 namespace { |
93 | 111 |
94 class ProfileTreeTestHelper { | 112 class ProfileTreeTestHelper { |
95 public: | 113 public: |
96 explicit ProfileTreeTestHelper(const ProfileTree* tree) | 114 explicit ProfileTreeTestHelper(const ProfileTree* tree) |
97 : tree_(tree) { } | 115 : tree_(tree) { } |
98 | 116 |
99 ProfileNode* Walk(CodeEntry* entry1, | 117 ProfileNode* Walk(CodeEntry* entry1, |
100 CodeEntry* entry2 = NULL, | 118 CodeEntry* entry2 = NULL, |
101 CodeEntry* entry3 = NULL) { | 119 CodeEntry* entry3 = NULL) { |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. | 804 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. |
787 titles[i] = title.start(); | 805 titles[i] = title.start(); |
788 } | 806 } |
789 CHECK(!collection.StartProfiling( | 807 CHECK(!collection.StartProfiling( |
790 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); | 808 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); |
791 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 809 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
792 i::DeleteArray(titles[i]); | 810 i::DeleteArray(titles[i]); |
793 } | 811 } |
794 | 812 |
795 #endif // ENABLE_LOGGING_AND_PROFILING | 813 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |