| Index: test/cctest/test-cpu-profiler.cc
|
| diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
|
| index 95930b4c2d5d6ee1da80890f779b6ad6c20ea345..8111b0bcf34b380163285e91c79a1feb35eb7cc5 100644
|
| --- a/test/cctest/test-cpu-profiler.cc
|
| +++ b/test/cctest/test-cpu-profiler.cc
|
| @@ -32,6 +32,7 @@
|
| #include "cpu-profiler-inl.h"
|
| #include "cctest.h"
|
| #include "utils.h"
|
| +#include "profiler-extension.h"
|
| #include "../include/v8-profiler.h"
|
| #undef V8_DISABLE_DEPRECATIONS
|
|
|
| @@ -920,40 +921,34 @@ 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;
|
| + const char* extensions[] = { i::ProfilerExtension::kName };
|
| + v8::ExtensionConfiguration config(1, extensions);
|
| + LocalContext env(&config);
|
| v8::HandleScope scope(env->GetIsolate());
|
|
|
| v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run();
|
| + v8::Local<v8::Object> global = env->Global();
|
| v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
|
| - env->Global()->Get(v8::String::New("start")));
|
| + global->Get(v8::String::New("start")));
|
| v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
|
| - int32_t profiling_interval_ms = 200;
|
| -#if defined(_WIN32) || defined(_WIN64)
|
| - // 200ms is not enough on Windows. See
|
| - // https://code.google.com/p/v8/issues/detail?id=2628
|
| - profiling_interval_ms = 500;
|
| -#endif
|
| + 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.
|
| @@ -969,28 +964,29 @@ TEST(SourceURLSupportForNewFunctions) {
|
| }
|
|
|
| TEST(LogExistingFunctionSourceURLCheck) {
|
| - LocalContext env;
|
| + const char* extensions[] = { i::ProfilerExtension::kName };
|
| + v8::ExtensionConfiguration config(1, extensions);
|
| + LocalContext env(&config);
|
| v8::HandleScope scope(env->GetIsolate());
|
|
|
| v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run();
|
| + v8::Local<v8::Object> global = env->Global();
|
| v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
|
| - env->Global()->Get(v8::String::New("start")));
|
| + global->Get(v8::String::New("start")));
|
| v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
|
| - int32_t profiling_interval_ms = 200;
|
| + 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());
|
|
|
| -#if defined(_WIN32) || defined(_WIN64)
|
| - // 200ms is not enough on Windows. See
|
| - // https://code.google.com/p/v8/issues/detail?id=2628
|
| - profiling_interval_ms = 500;
|
| -#endif
|
| - 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.
|
|
|