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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cpu-profiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 3fb5d3ae2cb636888b69e6acb52579ceafede81d..8ec96053381a6e211690d9f505bb11725a26dcd1 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -411,11 +411,13 @@ TEST(ProfileStartEndTime) {
static const v8::CpuProfile* RunProfiler(
LocalContext& env, v8::Handle<v8::Function> function,
v8::Handle<v8::Value> argv[], int argc,
- unsigned min_js_samples) {
+ unsigned min_js_samples, bool script_will_start_profiler = false) {
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
v8::Local<v8::String> profile_name = v8::String::New("my_profile");
- cpu_profiler->StartCpuProfiling(profile_name);
+ if (!script_will_start_profiler) {
+ cpu_profiler->StartCpuProfiling(profile_name);
+ }
i::Sampler* sampler =
reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
@@ -475,7 +477,12 @@ static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node,
static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
const char* name) {
const v8::CpuProfileNode* result = FindChild(node, name);
- CHECK(result);
+ if (!result) {
+ char buffer[100];
+ i::OS::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)),
+ "Failed to GetChild: %s", name);
+ FATAL(buffer);
+ }
return result;
}
@@ -590,7 +597,7 @@ static const char* cpu_profiler_test_source2 = "function loop() {}\n"
" } while (++k < count*100*1000);\n"
"}\n";
-// Check that the profile tree doesn't contain unexpecte traces:
+// Check that the profile tree doesn't contain unexpected traces:
// - 'loop' can be called only by 'delay'
// - 'delay' may be called only by 'start'
// The profile will look like the following:
@@ -1081,7 +1088,13 @@ TEST(FunctionApplySample) {
}
-static const char* js_native_js_test_source = "function foo(iterations) {\n"
+static const char* js_native_js_test_source =
+"var is_profiling = false;\n"
+"function foo(iterations) {\n"
+" if (!is_profiling) {\n"
+" is_profiling = true;\n"
+" startProfiling('my_profile');\n"
+" }\n"
" var r = 0;\n"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1113,7 +1126,9 @@ static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) {
// 55 1 bar #16 5
// 54 54 foo #16 6
TEST(JsNativeJsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
@@ -1129,7 +1144,7 @@ TEST(JsNativeJsSample) {
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
const v8::CpuProfile* profile =
- RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
+ RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
{
@@ -1157,7 +1172,12 @@ TEST(JsNativeJsSample) {
static const char* js_native_js_runtime_js_test_source =
+"var is_profiling = false;\n"
"function foo(iterations) {\n"
+" if (!is_profiling) {\n"
+" is_profiling = true;\n"
+" startProfiling('my_profile');\n"
+" }\n"
" var r = 0;\n"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1184,7 +1204,9 @@ static const char* js_native_js_runtime_js_test_source =
// 51 51 foo #16 6
// 2 2 (program) #0 2
TEST(JsNativeJsRuntimeJsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
@@ -1201,7 +1223,7 @@ TEST(JsNativeJsRuntimeJsSample) {
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
const v8::CpuProfile* profile =
- RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
+ RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
@@ -1232,7 +1254,12 @@ static void CallJsFunction2(const v8::FunctionCallbackInfo<v8::Value>& info) {
static const char* js_native1_js_native2_js_test_source =
+"var is_profiling = false;\n"
"function foo(iterations) {\n"
+" if (!is_profiling) {\n"
+" is_profiling = true;\n"
+" startProfiling('my_profile');\n"
+" }\n"
" var r = 0;\n"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1259,7 +1286,9 @@ static const char* js_native1_js_native2_js_test_source =
// 54 54 foo #16 7
// 2 2 (program) #0 2
TEST(JsNative1JsNative2JsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
@@ -1281,7 +1310,7 @@ TEST(JsNative1JsNative2JsSample) {
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
const v8::CpuProfile* profile =
- RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
+ RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
« 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