Chromium Code Reviews| Index: test/cctest/test-cpu-profiler.cc |
| diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc |
| index e351407495a9a2b4552b8f2e9201ff31eda97b4b..51c162066f960ce969ae67c7cdda9ebda8d11b0c 100644 |
| --- a/test/cctest/test-cpu-profiler.cc |
| +++ b/test/cctest/test-cpu-profiler.cc |
| @@ -920,35 +920,36 @@ TEST(NativeMethodMonomorphicIC) { |
| static const char* cpu_profiler_sourceURL_source = |
| -"function start(timeout) {\n" |
| -" var start = Date.now();\n" |
| -" var duration = 0;\n" |
| -" do {\n" |
| -" try {\n" |
| -" duration = Date.now() - start;\n" |
| -" } catch(e) { }\n" |
| -" } while (duration < timeout);\n" |
| -" return duration;\n" |
| +"function start(warm_up) {\n" |
| +" if (!warm_up) {\n" |
| +" startProfiling();\n" |
| +" stopProfiling();\n" |
| +" }\n" |
| "}\n" |
| "//# sourceURL=cpu_profiler_sourceURL_source.js"; |
| TEST(SourceURLSupportForNewFunctions) { |
| - LocalContext env; |
| - v8::HandleScope scope(env->GetIsolate()); |
| + v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| + v8::HandleScope scope(isolate); |
| + const char* extensions[] = { "v8/profiler" }; |
| + v8::ExtensionConfiguration config(1, extensions); |
| + v8::Local<v8::Context> context = v8::Context::New(isolate, &config); |
|
yurys
2013/06/13 09:11:35
Can you continue using LocalContext for consistenc
loislo
2013/06/13 10:01:42
Done.
|
| + context->Enter(); |
| v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); |
| + v8::Local<v8::Object> global = context->Global(); |
| v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| - env->Global()->Get(v8::String::New("start"))); |
| - v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| - int32_t profiling_interval_ms = 100; |
| + global->Get(v8::String::New("start"))); |
| + v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler(); |
| + CHECK_NE(NULL, cpu_profiler); |
| + CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
| // Cold run. |
| - v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
| - cpu_profiler->StartCpuProfiling(profile_name); |
| - v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; |
| - function->Call(env->Global(), ARRAY_SIZE(args), args); |
| - const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); |
| + v8::Handle<v8::Value> args[] = { v8::Boolean::New(false) }; |
| + function->Call(global, ARRAY_SIZE(args), args); |
| + CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
| + const v8::CpuProfile* profile = cpu_profiler->GetCpuProfile(0); |
| CHECK_NE(NULL, profile); |
| // Dump collected profile to have a better diagnostic in case of failure. |
| @@ -964,23 +965,31 @@ TEST(SourceURLSupportForNewFunctions) { |
| } |
| TEST(LogExistingFunctionSourceURLCheck) { |
| - LocalContext env; |
| - v8::HandleScope scope(env->GetIsolate()); |
| + v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| + v8::HandleScope scope(isolate); |
| + const char* extensions[] = { "v8/profiler" }; |
| + v8::ExtensionConfiguration config(1, extensions); |
| + v8::Local<v8::Context> context = v8::Context::New(isolate, &config); |
|
yurys
2013/06/13 09:11:35
Ditto.
loislo
2013/06/13 10:01:42
Done.
|
| + context->Enter(); |
| v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); |
| + v8::Local<v8::Object> global = context->Global(); |
| v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| - env->Global()->Get(v8::String::New("start"))); |
| - v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| - int32_t profiling_interval_ms = 100; |
| + global->Get(v8::String::New("start"))); |
| + v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler(); |
| + CHECK_NE(NULL, cpu_profiler); |
| + CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
| // Warm up. |
| - v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; |
| - function->Call(env->Global(), ARRAY_SIZE(args), args); |
| + v8::Handle<v8::Value> warm_up_args[] = { v8::Boolean::New(true) }; |
| + function->Call(global, ARRAY_SIZE(warm_up_args), warm_up_args); |
| + CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
| - v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
| - cpu_profiler->StartCpuProfiling(profile_name); |
| - function->Call(env->Global(), ARRAY_SIZE(args), args); |
| - const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); |
| + // Run. |
| + v8::Handle<v8::Value> args[] = { v8::Boolean::New(false) }; |
| + function->Call(global, ARRAY_SIZE(args), args); |
| + CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
| + const v8::CpuProfile* profile = cpu_profiler->GetCpuProfile(0); |
| CHECK_NE(NULL, profile); |
| // Dump collected profile to have a better diagnostic in case of failure. |