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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 25686011: Unflake cctest/test-cpu-profiler/JsNativeJsRuntimeJsSample on Win32 Debug (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 v8::Local<v8::String> profile_name = v8::String::New("test"); 404 v8::Local<v8::String> profile_name = v8::String::New("test");
405 cpu_profiler->StartCpuProfiling(profile_name); 405 cpu_profiler->StartCpuProfiling(profile_name);
406 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); 406 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
407 CHECK(profile->GetStartTime() <= profile->GetEndTime()); 407 CHECK(profile->GetStartTime() <= profile->GetEndTime());
408 } 408 }
409 409
410 410
411 static const v8::CpuProfile* RunProfiler( 411 static const v8::CpuProfile* RunProfiler(
412 LocalContext& env, v8::Handle<v8::Function> function, 412 LocalContext& env, v8::Handle<v8::Function> function,
413 v8::Handle<v8::Value> argv[], int argc, 413 v8::Handle<v8::Value> argv[], int argc,
414 unsigned min_js_samples) { 414 unsigned min_js_samples, bool script_will_start_profiler = false) {
415 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 415 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
416 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); 416 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
417 417
418 cpu_profiler->StartCpuProfiling(profile_name); 418 if (!script_will_start_profiler) {
419 cpu_profiler->StartCpuProfiling(profile_name);
420 }
419 421
420 i::Sampler* sampler = 422 i::Sampler* sampler =
421 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); 423 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
422 sampler->StartCountingSamples(); 424 sampler->StartCountingSamples();
423 do { 425 do {
424 function->Call(env->Global(), argc, argv); 426 function->Call(env->Global(), argc, argv);
425 } while (sampler->js_and_external_sample_count() < min_js_samples); 427 } while (sampler->js_and_external_sample_count() < min_js_samples);
426 428
427 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); 429 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
428 430
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 const v8::CpuProfileNode* child = node->GetChild(i); 470 const v8::CpuProfileNode* child = node->GetChild(i);
469 if (nameHandle->Equals(child->GetFunctionName())) return child; 471 if (nameHandle->Equals(child->GetFunctionName())) return child;
470 } 472 }
471 return NULL; 473 return NULL;
472 } 474 }
473 475
474 476
475 static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node, 477 static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
476 const char* name) { 478 const char* name) {
477 const v8::CpuProfileNode* result = FindChild(node, name); 479 const v8::CpuProfileNode* result = FindChild(node, name);
478 CHECK(result); 480 if (!result) {
481 char buffer[100];
482 i::OS::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)),
483 "Failed to GetChild: %s", name);
484 FATAL(buffer);
485 }
479 return result; 486 return result;
480 } 487 }
481 488
482 489
483 static void CheckSimpleBranch(const v8::CpuProfileNode* node, 490 static void CheckSimpleBranch(const v8::CpuProfileNode* node,
484 const char* names[], int length) { 491 const char* names[], int length) {
485 for (int i = 0; i < length; i++) { 492 for (int i = 0; i < length; i++) {
486 const char* name = names[i]; 493 const char* name = names[i];
487 node = GetChild(node, name); 494 node = GetChild(node, name);
488 int expectedChildrenCount = (i == length - 1) ? 0 : 1; 495 int expectedChildrenCount = (i == length - 1) ? 0 : 1;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 590
584 static const char* cpu_profiler_test_source2 = "function loop() {}\n" 591 static const char* cpu_profiler_test_source2 = "function loop() {}\n"
585 "function delay() { loop(); }\n" 592 "function delay() { loop(); }\n"
586 "function start(count) {\n" 593 "function start(count) {\n"
587 " var k = 0;\n" 594 " var k = 0;\n"
588 " do {\n" 595 " do {\n"
589 " delay();\n" 596 " delay();\n"
590 " } while (++k < count*100*1000);\n" 597 " } while (++k < count*100*1000);\n"
591 "}\n"; 598 "}\n";
592 599
593 // Check that the profile tree doesn't contain unexpecte traces: 600 // Check that the profile tree doesn't contain unexpected traces:
594 // - 'loop' can be called only by 'delay' 601 // - 'loop' can be called only by 'delay'
595 // - 'delay' may be called only by 'start' 602 // - 'delay' may be called only by 'start'
596 // The profile will look like the following: 603 // The profile will look like the following:
597 // 604 //
598 // [Top down]: 605 // [Top down]:
599 // 135 0 (root) [-1] #1 606 // 135 0 (root) [-1] #1
600 // 121 72 start [-1] #3 607 // 121 72 start [-1] #3
601 // 49 33 delay [-1] #4 608 // 49 33 delay [-1] #4
602 // 16 16 loop [-1] #5 609 // 16 16 loop [-1] #5
603 // 14 14 (program) [-1] #2 610 // 14 14 (program) [-1] #2
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 CheckChildrenNames(unresolvedNode, names); 1081 CheckChildrenNames(unresolvedNode, names);
1075 GetChild(unresolvedNode, "apply"); 1082 GetChild(unresolvedNode, "apply");
1076 } 1083 }
1077 } 1084 }
1078 1085
1079 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1086 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1080 cpu_profiler->DeleteAllCpuProfiles(); 1087 cpu_profiler->DeleteAllCpuProfiles();
1081 } 1088 }
1082 1089
1083 1090
1084 static const char* js_native_js_test_source = "function foo(iterations) {\n" 1091 static const char* js_native_js_test_source =
1092 "var is_profiling = false;\n"
1093 "function foo(iterations) {\n"
1094 " if (!is_profiling) {\n"
1095 " is_profiling = true;\n"
1096 " startProfiling('my_profile');\n"
1097 " }\n"
1085 " var r = 0;\n" 1098 " var r = 0;\n"
1086 " for (var i = 0; i < iterations; i++) { r += i; }\n" 1099 " for (var i = 0; i < iterations; i++) { r += i; }\n"
1087 " return r;\n" 1100 " return r;\n"
1088 "}\n" 1101 "}\n"
1089 "function bar(iterations) {\n" 1102 "function bar(iterations) {\n"
1090 " try { foo(iterations); } catch(e) {}\n" 1103 " try { foo(iterations); } catch(e) {}\n"
1091 "}\n" 1104 "}\n"
1092 "function start(duration) {\n" 1105 "function start(duration) {\n"
1093 " var start = Date.now();\n" 1106 " var start = Date.now();\n"
1094 " while (Date.now() - start < duration) {\n" 1107 " while (Date.now() - start < duration) {\n"
(...skipping 11 matching lines...) Expand all
1106 1119
1107 1120
1108 // [Top down]: 1121 // [Top down]:
1109 // 58 0 (root) #0 1 1122 // 58 0 (root) #0 1
1110 // 2 2 (program) #0 2 1123 // 2 2 (program) #0 2
1111 // 56 1 start #16 3 1124 // 56 1 start #16 3
1112 // 55 0 CallJsFunction #0 4 1125 // 55 0 CallJsFunction #0 4
1113 // 55 1 bar #16 5 1126 // 55 1 bar #16 5
1114 // 54 54 foo #16 6 1127 // 54 54 foo #16 6
1115 TEST(JsNativeJsSample) { 1128 TEST(JsNativeJsSample) {
1116 LocalContext env; 1129 const char* extensions[] = { "v8/profiler" };
1130 v8::ExtensionConfiguration config(1, extensions);
1131 LocalContext env(&config);
1117 v8::HandleScope scope(env->GetIsolate()); 1132 v8::HandleScope scope(env->GetIsolate());
1118 1133
1119 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1134 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1120 CallJsFunction); 1135 CallJsFunction);
1121 v8::Local<v8::Function> func = func_template->GetFunction(); 1136 v8::Local<v8::Function> func = func_template->GetFunction();
1122 func->SetName(v8::String::New("CallJsFunction")); 1137 func->SetName(v8::String::New("CallJsFunction"));
1123 env->Global()->Set(v8::String::New("CallJsFunction"), func); 1138 env->Global()->Set(v8::String::New("CallJsFunction"), func);
1124 1139
1125 v8::Script::Compile(v8::String::New(js_native_js_test_source))->Run(); 1140 v8::Script::Compile(v8::String::New(js_native_js_test_source))->Run();
1126 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1141 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1127 env->Global()->Get(v8::String::New("start"))); 1142 env->Global()->Get(v8::String::New("start")));
1128 1143
1129 int32_t duration_ms = 20; 1144 int32_t duration_ms = 20;
1130 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; 1145 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
1131 const v8::CpuProfile* profile = 1146 const v8::CpuProfile* profile =
1132 RunProfiler(env, function, args, ARRAY_SIZE(args), 50); 1147 RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
1133 1148
1134 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1149 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1135 { 1150 {
1136 ScopedVector<v8::Handle<v8::String> > names(3); 1151 ScopedVector<v8::Handle<v8::String> > names(3);
1137 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName); 1152 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
1138 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName); 1153 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
1139 names[2] = v8::String::New("start"); 1154 names[2] = v8::String::New("start");
1140 CheckChildrenNames(root, names); 1155 CheckChildrenNames(root, names);
1141 } 1156 }
1142 1157
1143 const v8::CpuProfileNode* startNode = GetChild(root, "start"); 1158 const v8::CpuProfileNode* startNode = GetChild(root, "start");
1144 CHECK_EQ(1, startNode->GetChildrenCount()); 1159 CHECK_EQ(1, startNode->GetChildrenCount());
1145 const v8::CpuProfileNode* nativeFunctionNode = 1160 const v8::CpuProfileNode* nativeFunctionNode =
1146 GetChild(startNode, "CallJsFunction"); 1161 GetChild(startNode, "CallJsFunction");
1147 1162
1148 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount()); 1163 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount());
1149 const v8::CpuProfileNode* barNode = GetChild(nativeFunctionNode, "bar"); 1164 const v8::CpuProfileNode* barNode = GetChild(nativeFunctionNode, "bar");
1150 1165
1151 CHECK_EQ(1, barNode->GetChildrenCount()); 1166 CHECK_EQ(1, barNode->GetChildrenCount());
1152 GetChild(barNode, "foo"); 1167 GetChild(barNode, "foo");
1153 1168
1154 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1169 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1155 cpu_profiler->DeleteAllCpuProfiles(); 1170 cpu_profiler->DeleteAllCpuProfiles();
1156 } 1171 }
1157 1172
1158 1173
1159 static const char* js_native_js_runtime_js_test_source = 1174 static const char* js_native_js_runtime_js_test_source =
1175 "var is_profiling = false;\n"
1160 "function foo(iterations) {\n" 1176 "function foo(iterations) {\n"
1177 " if (!is_profiling) {\n"
1178 " is_profiling = true;\n"
1179 " startProfiling('my_profile');\n"
1180 " }\n"
1161 " var r = 0;\n" 1181 " var r = 0;\n"
1162 " for (var i = 0; i < iterations; i++) { r += i; }\n" 1182 " for (var i = 0; i < iterations; i++) { r += i; }\n"
1163 " return r;\n" 1183 " return r;\n"
1164 "}\n" 1184 "}\n"
1165 "var bound = foo.bind(this);\n" 1185 "var bound = foo.bind(this);\n"
1166 "function bar(iterations) {\n" 1186 "function bar(iterations) {\n"
1167 " try { bound(iterations); } catch(e) {}\n" 1187 " try { bound(iterations); } catch(e) {}\n"
1168 "}\n" 1188 "}\n"
1169 "function start(duration) {\n" 1189 "function start(duration) {\n"
1170 " var start = Date.now();\n" 1190 " var start = Date.now();\n"
1171 " while (Date.now() - start < duration) {\n" 1191 " while (Date.now() - start < duration) {\n"
1172 " try {\n" 1192 " try {\n"
1173 " CallJsFunction(bar, 10 * 1000);\n" 1193 " CallJsFunction(bar, 10 * 1000);\n"
1174 " } catch(e) {}\n" 1194 " } catch(e) {}\n"
1175 " }\n" 1195 " }\n"
1176 "}"; 1196 "}";
1177 1197
1178 1198
1179 // [Top down]: 1199 // [Top down]:
1180 // 57 0 (root) #0 1 1200 // 57 0 (root) #0 1
1181 // 55 1 start #16 3 1201 // 55 1 start #16 3
1182 // 54 0 CallJsFunction #0 4 1202 // 54 0 CallJsFunction #0 4
1183 // 54 3 bar #16 5 1203 // 54 3 bar #16 5
1184 // 51 51 foo #16 6 1204 // 51 51 foo #16 6
1185 // 2 2 (program) #0 2 1205 // 2 2 (program) #0 2
1186 TEST(JsNativeJsRuntimeJsSample) { 1206 TEST(JsNativeJsRuntimeJsSample) {
1187 LocalContext env; 1207 const char* extensions[] = { "v8/profiler" };
1208 v8::ExtensionConfiguration config(1, extensions);
1209 LocalContext env(&config);
1188 v8::HandleScope scope(env->GetIsolate()); 1210 v8::HandleScope scope(env->GetIsolate());
1189 1211
1190 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1212 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1191 CallJsFunction); 1213 CallJsFunction);
1192 v8::Local<v8::Function> func = func_template->GetFunction(); 1214 v8::Local<v8::Function> func = func_template->GetFunction();
1193 func->SetName(v8::String::New("CallJsFunction")); 1215 func->SetName(v8::String::New("CallJsFunction"));
1194 env->Global()->Set(v8::String::New("CallJsFunction"), func); 1216 env->Global()->Set(v8::String::New("CallJsFunction"), func);
1195 1217
1196 v8::Script::Compile(v8::String::New(js_native_js_runtime_js_test_source))-> 1218 v8::Script::Compile(v8::String::New(js_native_js_runtime_js_test_source))->
1197 Run(); 1219 Run();
1198 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1220 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1199 env->Global()->Get(v8::String::New("start"))); 1221 env->Global()->Get(v8::String::New("start")));
1200 1222
1201 int32_t duration_ms = 20; 1223 int32_t duration_ms = 20;
1202 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; 1224 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
1203 const v8::CpuProfile* profile = 1225 const v8::CpuProfile* profile =
1204 RunProfiler(env, function, args, ARRAY_SIZE(args), 50); 1226 RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
1205 1227
1206 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1228 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1207 ScopedVector<v8::Handle<v8::String> > names(3); 1229 ScopedVector<v8::Handle<v8::String> > names(3);
1208 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName); 1230 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
1209 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName); 1231 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
1210 names[2] = v8::String::New("start"); 1232 names[2] = v8::String::New("start");
1211 CheckChildrenNames(root, names); 1233 CheckChildrenNames(root, names);
1212 1234
1213 const v8::CpuProfileNode* startNode = GetChild(root, "start"); 1235 const v8::CpuProfileNode* startNode = GetChild(root, "start");
1214 CHECK_EQ(1, startNode->GetChildrenCount()); 1236 CHECK_EQ(1, startNode->GetChildrenCount());
(...skipping 10 matching lines...) Expand all
1225 cpu_profiler->DeleteAllCpuProfiles(); 1247 cpu_profiler->DeleteAllCpuProfiles();
1226 } 1248 }
1227 1249
1228 1250
1229 static void CallJsFunction2(const v8::FunctionCallbackInfo<v8::Value>& info) { 1251 static void CallJsFunction2(const v8::FunctionCallbackInfo<v8::Value>& info) {
1230 CallJsFunction(info); 1252 CallJsFunction(info);
1231 } 1253 }
1232 1254
1233 1255
1234 static const char* js_native1_js_native2_js_test_source = 1256 static const char* js_native1_js_native2_js_test_source =
1257 "var is_profiling = false;\n"
1235 "function foo(iterations) {\n" 1258 "function foo(iterations) {\n"
1259 " if (!is_profiling) {\n"
1260 " is_profiling = true;\n"
1261 " startProfiling('my_profile');\n"
1262 " }\n"
1236 " var r = 0;\n" 1263 " var r = 0;\n"
1237 " for (var i = 0; i < iterations; i++) { r += i; }\n" 1264 " for (var i = 0; i < iterations; i++) { r += i; }\n"
1238 " return r;\n" 1265 " return r;\n"
1239 "}\n" 1266 "}\n"
1240 "function bar(iterations) {\n" 1267 "function bar(iterations) {\n"
1241 " CallJsFunction2(foo, iterations);\n" 1268 " CallJsFunction2(foo, iterations);\n"
1242 "}\n" 1269 "}\n"
1243 "function start(duration) {\n" 1270 "function start(duration) {\n"
1244 " var start = Date.now();\n" 1271 " var start = Date.now();\n"
1245 " while (Date.now() - start < duration) {\n" 1272 " while (Date.now() - start < duration) {\n"
1246 " try {\n" 1273 " try {\n"
1247 " CallJsFunction1(bar, 10 * 1000);\n" 1274 " CallJsFunction1(bar, 10 * 1000);\n"
1248 " } catch(e) {}\n" 1275 " } catch(e) {}\n"
1249 " }\n" 1276 " }\n"
1250 "}"; 1277 "}";
1251 1278
1252 1279
1253 // [Top down]: 1280 // [Top down]:
1254 // 57 0 (root) #0 1 1281 // 57 0 (root) #0 1
1255 // 55 1 start #16 3 1282 // 55 1 start #16 3
1256 // 54 0 CallJsFunction1 #0 4 1283 // 54 0 CallJsFunction1 #0 4
1257 // 54 0 bar #16 5 1284 // 54 0 bar #16 5
1258 // 54 0 CallJsFunction2 #0 6 1285 // 54 0 CallJsFunction2 #0 6
1259 // 54 54 foo #16 7 1286 // 54 54 foo #16 7
1260 // 2 2 (program) #0 2 1287 // 2 2 (program) #0 2
1261 TEST(JsNative1JsNative2JsSample) { 1288 TEST(JsNative1JsNative2JsSample) {
1262 LocalContext env; 1289 const char* extensions[] = { "v8/profiler" };
1290 v8::ExtensionConfiguration config(1, extensions);
1291 LocalContext env(&config);
1263 v8::HandleScope scope(env->GetIsolate()); 1292 v8::HandleScope scope(env->GetIsolate());
1264 1293
1265 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1294 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1266 CallJsFunction); 1295 CallJsFunction);
1267 v8::Local<v8::Function> func1 = func_template->GetFunction(); 1296 v8::Local<v8::Function> func1 = func_template->GetFunction();
1268 func1->SetName(v8::String::New("CallJsFunction1")); 1297 func1->SetName(v8::String::New("CallJsFunction1"));
1269 env->Global()->Set(v8::String::New("CallJsFunction1"), func1); 1298 env->Global()->Set(v8::String::New("CallJsFunction1"), func1);
1270 1299
1271 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( 1300 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New(
1272 CallJsFunction2)->GetFunction(); 1301 CallJsFunction2)->GetFunction();
1273 func2->SetName(v8::String::New("CallJsFunction2")); 1302 func2->SetName(v8::String::New("CallJsFunction2"));
1274 env->Global()->Set(v8::String::New("CallJsFunction2"), func2); 1303 env->Global()->Set(v8::String::New("CallJsFunction2"), func2);
1275 1304
1276 v8::Script::Compile(v8::String::New(js_native1_js_native2_js_test_source))-> 1305 v8::Script::Compile(v8::String::New(js_native1_js_native2_js_test_source))->
1277 Run(); 1306 Run();
1278 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1307 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1279 env->Global()->Get(v8::String::New("start"))); 1308 env->Global()->Get(v8::String::New("start")));
1280 1309
1281 int32_t duration_ms = 20; 1310 int32_t duration_ms = 20;
1282 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; 1311 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
1283 const v8::CpuProfile* profile = 1312 const v8::CpuProfile* profile =
1284 RunProfiler(env, function, args, ARRAY_SIZE(args), 50); 1313 RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
1285 1314
1286 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1315 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1287 ScopedVector<v8::Handle<v8::String> > names(3); 1316 ScopedVector<v8::Handle<v8::String> > names(3);
1288 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName); 1317 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
1289 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName); 1318 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
1290 names[2] = v8::String::New("start"); 1319 names[2] = v8::String::New("start");
1291 CheckChildrenNames(root, names); 1320 CheckChildrenNames(root, names);
1292 1321
1293 const v8::CpuProfileNode* startNode = GetChild(root, "start"); 1322 const v8::CpuProfileNode* startNode = GetChild(root, "start");
1294 CHECK_EQ(1, startNode->GetChildrenCount()); 1323 CHECK_EQ(1, startNode->GetChildrenCount());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 CHECK_EQ(0, programNode->GetChildrenCount()); 1382 CHECK_EQ(0, programNode->GetChildrenCount());
1354 CHECK_GE(programNode->GetHitCount(), 3); 1383 CHECK_GE(programNode->GetHitCount(), 3);
1355 1384
1356 const v8::CpuProfileNode* idleNode = 1385 const v8::CpuProfileNode* idleNode =
1357 GetChild(root, ProfileGenerator::kIdleEntryName); 1386 GetChild(root, ProfileGenerator::kIdleEntryName);
1358 CHECK_EQ(0, idleNode->GetChildrenCount()); 1387 CHECK_EQ(0, idleNode->GetChildrenCount());
1359 CHECK_GE(idleNode->GetHitCount(), 3); 1388 CHECK_GE(idleNode->GetHitCount(), 3);
1360 1389
1361 cpu_profiler->DeleteAllCpuProfiles(); 1390 cpu_profiler->DeleteAllCpuProfiles();
1362 } 1391 }
OLDNEW
« no previous file with comments | « src/cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698