OLD | NEW |
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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 | 934 |
935 | 935 |
936 TEST(SourceURLSupportForNewFunctions) { | 936 TEST(SourceURLSupportForNewFunctions) { |
937 LocalContext env; | 937 LocalContext env; |
938 v8::HandleScope scope(env->GetIsolate()); | 938 v8::HandleScope scope(env->GetIsolate()); |
939 | 939 |
940 v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); | 940 v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); |
941 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 941 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
942 env->Global()->Get(v8::String::New("start"))); | 942 env->Global()->Get(v8::String::New("start"))); |
943 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 943 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
944 int32_t profiling_interval_ms = 100; | 944 int32_t profiling_interval_ms = 200; |
| 945 #if defined(_WIN32) || defined(_WIN64) |
| 946 // 200ms is not enough on Windows. See |
| 947 // https://code.google.com/p/v8/issues/detail?id=2628 |
| 948 profiling_interval_ms = 500; |
| 949 #endif |
945 | 950 |
946 // Cold run. | 951 // Cold run. |
947 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); | 952 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
948 cpu_profiler->StartCpuProfiling(profile_name); | 953 cpu_profiler->StartCpuProfiling(profile_name); |
949 v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; | 954 v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; |
950 function->Call(env->Global(), ARRAY_SIZE(args), args); | 955 function->Call(env->Global(), ARRAY_SIZE(args), args); |
951 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); | 956 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); |
952 CHECK_NE(NULL, profile); | 957 CHECK_NE(NULL, profile); |
953 | 958 |
954 // Dump collected profile to have a better diagnostic in case of failure. | 959 // Dump collected profile to have a better diagnostic in case of failure. |
955 reinterpret_cast<i::CpuProfile*>( | 960 reinterpret_cast<i::CpuProfile*>( |
956 const_cast<v8::CpuProfile*>(profile))->Print(); | 961 const_cast<v8::CpuProfile*>(profile))->Print(); |
957 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 962 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
958 const v8::CpuProfileNode* startNode = GetChild(root, "start"); | 963 const v8::CpuProfileNode* startNode = GetChild(root, "start"); |
959 | 964 |
960 CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"), | 965 CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"), |
961 startNode->GetScriptResourceName()); | 966 startNode->GetScriptResourceName()); |
962 | 967 |
963 cpu_profiler->DeleteAllCpuProfiles(); | 968 cpu_profiler->DeleteAllCpuProfiles(); |
964 } | 969 } |
965 | 970 |
966 TEST(LogExistingFunctionSourceURLCheck) { | 971 TEST(LogExistingFunctionSourceURLCheck) { |
967 LocalContext env; | 972 LocalContext env; |
968 v8::HandleScope scope(env->GetIsolate()); | 973 v8::HandleScope scope(env->GetIsolate()); |
969 | 974 |
970 v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); | 975 v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run(); |
971 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 976 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
972 env->Global()->Get(v8::String::New("start"))); | 977 env->Global()->Get(v8::String::New("start"))); |
973 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 978 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
974 int32_t profiling_interval_ms = 100; | 979 int32_t profiling_interval_ms = 200; |
975 | 980 |
976 // Warm up. | 981 // Warm up. |
977 v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; | 982 v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) }; |
978 function->Call(env->Global(), ARRAY_SIZE(args), args); | 983 function->Call(env->Global(), ARRAY_SIZE(args), args); |
979 | 984 |
| 985 #if defined(_WIN32) || defined(_WIN64) |
| 986 // 200ms is not enough on Windows. See |
| 987 // https://code.google.com/p/v8/issues/detail?id=2628 |
| 988 profiling_interval_ms = 500; |
| 989 #endif |
980 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); | 990 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
981 cpu_profiler->StartCpuProfiling(profile_name); | 991 cpu_profiler->StartCpuProfiling(profile_name); |
982 function->Call(env->Global(), ARRAY_SIZE(args), args); | 992 function->Call(env->Global(), ARRAY_SIZE(args), args); |
983 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); | 993 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); |
984 CHECK_NE(NULL, profile); | 994 CHECK_NE(NULL, profile); |
985 | 995 |
986 // Dump collected profile to have a better diagnostic in case of failure. | 996 // Dump collected profile to have a better diagnostic in case of failure. |
987 reinterpret_cast<i::CpuProfile*>( | 997 reinterpret_cast<i::CpuProfile*>( |
988 const_cast<v8::CpuProfile*>(profile))->Print(); | 998 const_cast<v8::CpuProfile*>(profile))->Print(); |
989 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 999 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
990 const v8::CpuProfileNode* startNode = GetChild(root, "start"); | 1000 const v8::CpuProfileNode* startNode = GetChild(root, "start"); |
991 CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"), | 1001 CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"), |
992 startNode->GetScriptResourceName()); | 1002 startNode->GetScriptResourceName()); |
993 | 1003 |
994 cpu_profiler->DeleteAllCpuProfiles(); | 1004 cpu_profiler->DeleteAllCpuProfiles(); |
995 } | 1005 } |
OLD | NEW |