OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 | 6 |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/profiler.h" | 10 #include "vm/profiler.h" |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 EXPECT(walker.Down()); | 1071 EXPECT(walker.Down()); |
1072 EXPECT_STREQ("B.choo", walker.CurrentName()); | 1072 EXPECT_STREQ("B.choo", walker.CurrentName()); |
1073 EXPECT_EQ(1, walker.SiblingCount()); | 1073 EXPECT_EQ(1, walker.SiblingCount()); |
1074 EXPECT_EQ(50000, walker.CurrentNodeTickCount()); | 1074 EXPECT_EQ(50000, walker.CurrentNodeTickCount()); |
1075 EXPECT_EQ(50000, walker.CurrentInclusiveTicks()); | 1075 EXPECT_EQ(50000, walker.CurrentInclusiveTicks()); |
1076 EXPECT_EQ(50000, walker.CurrentExclusiveTicks()); | 1076 EXPECT_EQ(50000, walker.CurrentExclusiveTicks()); |
1077 EXPECT(!walker.Down()); | 1077 EXPECT(!walker.Down()); |
1078 } | 1078 } |
1079 } | 1079 } |
1080 | 1080 |
1081 | |
1082 TEST_CASE(Profiler_ChainedSamples) { | |
1083 // Each sample holds 8 stack frames. | |
1084 // This chain is 20 stack frames deep. | |
1085 const char* kScript = | |
1086 "class A {\n" | |
1087 " var a;\n" | |
1088 " var b;\n" | |
1089 "}\n" | |
1090 "class B {\n" | |
1091 " static boo() {\n" | |
1092 " return new A();\n" | |
1093 " }\n" | |
1094 "}\n" | |
1095 "go() => init();\n" | |
1096 "init() => secondInit();\n" | |
1097 "secondInit() => apple();\n" | |
1098 "apple() => banana();\n" | |
1099 "banana() => cantaloupe();\n" | |
1100 "cantaloupe() => dog();\n" | |
1101 "dog() => elephant();\n" | |
1102 "elephant() => fred();\n" | |
1103 "fred() => granola();\n" | |
1104 "granola() => haystack();\n" | |
1105 "haystack() => ice();\n" | |
1106 "ice() => jeep();\n" | |
1107 "jeep() => kindle();\n" | |
1108 "kindle() => lemon();\n" | |
1109 "lemon() => mayo();\n" | |
1110 "mayo() => napkin();\n" | |
1111 "napkin() => orange();\n" | |
1112 "orange() => B.boo();\n" | |
1113 "main() {\n" | |
1114 " return go();\n" | |
1115 "}\n"; | |
1116 | |
1117 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | |
1118 EXPECT_VALID(lib); | |
1119 Library& root_library = Library::Handle(); | |
1120 root_library ^= Api::UnwrapHandle(lib); | |
1121 | |
1122 const Class& class_a = Class::Handle(GetClass(root_library, "A")); | |
1123 EXPECT(!class_a.IsNull()); | |
1124 class_a.SetTraceAllocation(true); | |
1125 | |
1126 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | |
1127 EXPECT_VALID(result); | |
1128 | |
1129 | |
1130 { | |
1131 Isolate* isolate = Isolate::Current(); | |
1132 StackZone zone(isolate); | |
1133 HANDLESCOPE(isolate); | |
siva
2015/08/04 21:33:09
We are trying to deprecate these APIs that use cur
Cutch
2015/08/05 13:49:13
Done here and elsewhere (in this file).
| |
1134 Profile profile(isolate); | |
1135 AllocationFilter filter(isolate, class_a.id()); | |
1136 profile.Build(&filter, Profile::kNoTags); | |
1137 // We should have 1 allocation sample. | |
1138 EXPECT_EQ(1, profile.sample_count()); | |
1139 ProfileTrieWalker walker(&profile); | |
1140 | |
1141 walker.Reset(Profile::kExclusiveCode); | |
1142 // Move down from the root. | |
1143 EXPECT(walker.Down()); | |
1144 EXPECT_STREQ("B.boo", walker.CurrentName()); | |
1145 EXPECT(walker.Down()); | |
1146 EXPECT_STREQ("orange", walker.CurrentName()); | |
1147 EXPECT(walker.Down()); | |
1148 EXPECT_STREQ("napkin", walker.CurrentName()); | |
1149 EXPECT(walker.Down()); | |
1150 EXPECT_STREQ("mayo", walker.CurrentName()); | |
1151 EXPECT(walker.Down()); | |
1152 EXPECT_STREQ("lemon", walker.CurrentName()); | |
1153 EXPECT(walker.Down()); | |
1154 EXPECT_STREQ("kindle", walker.CurrentName()); | |
1155 EXPECT(walker.Down()); | |
1156 EXPECT_STREQ("jeep", walker.CurrentName()); | |
1157 EXPECT(walker.Down()); | |
1158 EXPECT_STREQ("ice", walker.CurrentName()); | |
1159 EXPECT(walker.Down()); | |
1160 EXPECT_STREQ("haystack", walker.CurrentName()); | |
1161 EXPECT(walker.Down()); | |
1162 EXPECT_STREQ("granola", walker.CurrentName()); | |
1163 EXPECT(walker.Down()); | |
1164 EXPECT_STREQ("fred", walker.CurrentName()); | |
1165 EXPECT(walker.Down()); | |
1166 EXPECT_STREQ("elephant", walker.CurrentName()); | |
1167 EXPECT(walker.Down()); | |
1168 EXPECT_STREQ("dog", walker.CurrentName()); | |
1169 EXPECT(walker.Down()); | |
1170 EXPECT_STREQ("cantaloupe", walker.CurrentName()); | |
1171 EXPECT(walker.Down()); | |
1172 EXPECT_STREQ("banana", walker.CurrentName()); | |
1173 EXPECT(walker.Down()); | |
1174 EXPECT_STREQ("apple", walker.CurrentName()); | |
1175 EXPECT(walker.Down()); | |
1176 EXPECT_STREQ("secondInit", walker.CurrentName()); | |
1177 EXPECT(walker.Down()); | |
1178 EXPECT_STREQ("init", walker.CurrentName()); | |
1179 EXPECT(walker.Down()); | |
1180 EXPECT_STREQ("go", walker.CurrentName()); | |
1181 EXPECT(walker.Down()); | |
1182 EXPECT_STREQ("main", walker.CurrentName()); | |
1183 EXPECT(!walker.Down()); | |
1184 } | |
1185 } | |
1186 | |
1081 } // namespace dart | 1187 } // namespace dart |
OLD | NEW |