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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 // | 27 // |
28 // Tests of profiles generator and utilities. | 28 // Tests of profiles generator and utilities. |
29 | 29 |
30 #include "src/v8.h" | 30 #include "src/v8.h" |
31 | 31 |
32 #include "include/v8-profiler.h" | 32 #include "include/v8-profiler.h" |
| 33 #include "include/v8-sampler.h" |
33 #include "src/base/platform/platform.h" | 34 #include "src/base/platform/platform.h" |
34 #include "src/base/smart-pointers.h" | 35 #include "src/base/smart-pointers.h" |
35 #include "src/deoptimizer.h" | 36 #include "src/deoptimizer.h" |
36 #include "src/profiler/cpu-profiler-inl.h" | 37 #include "src/profiler/cpu-profiler-inl.h" |
37 #include "src/utils.h" | 38 #include "src/utils.h" |
38 #include "test/cctest/cctest.h" | 39 #include "test/cctest/cctest.h" |
39 #include "test/cctest/profiler-extension.h" | 40 #include "test/cctest/profiler-extension.h" |
40 using i::CodeEntry; | 41 using i::CodeEntry; |
41 using i::CpuProfile; | 42 using i::CpuProfile; |
42 using i::CpuProfiler; | 43 using i::CpuProfiler; |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 v8::Local<v8::Value> argv[], int argc, | 423 v8::Local<v8::Value> argv[], int argc, |
423 unsigned min_js_samples = 0, | 424 unsigned min_js_samples = 0, |
424 unsigned min_external_samples = 0, | 425 unsigned min_external_samples = 0, |
425 bool collect_samples = false) { | 426 bool collect_samples = false) { |
426 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 427 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
427 v8::Local<v8::String> profile_name = v8_str("my_profile"); | 428 v8::Local<v8::String> profile_name = v8_str("my_profile"); |
428 | 429 |
429 cpu_profiler->SetSamplingInterval(100); | 430 cpu_profiler->SetSamplingInterval(100); |
430 cpu_profiler->StartProfiling(profile_name, collect_samples); | 431 cpu_profiler->StartProfiling(profile_name, collect_samples); |
431 | 432 |
432 i::Sampler* sampler = | 433 v8::V8Sampler* sampler = |
433 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); | 434 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); |
434 sampler->StartCountingSamples(); | 435 sampler->StartCountingSamples(); |
435 do { | 436 do { |
436 function->Call(env, env->Global(), argc, argv).ToLocalChecked(); | 437 function->Call(env, env->Global(), argc, argv).ToLocalChecked(); |
437 } while (sampler->js_sample_count() < min_js_samples || | 438 } while (sampler->js_sample_count() < min_js_samples || |
438 sampler->external_sample_count() < min_external_samples); | 439 sampler->external_sample_count() < min_external_samples); |
439 | 440 |
440 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); | 441 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); |
441 | 442 |
442 CHECK(profile); | 443 CHECK(profile); |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 iprofile->Print(); | 1969 iprofile->Print(); |
1969 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 1970 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
1970 | 1971 |
1971 const char* branch[] = {"", "test"}; | 1972 const char* branch[] = {"", "test"}; |
1972 const ProfileNode* itest_node = | 1973 const ProfileNode* itest_node = |
1973 GetSimpleBranch(env, profile, branch, arraysize(branch)); | 1974 GetSimpleBranch(env, profile, branch, arraysize(branch)); |
1974 CHECK_EQ(0U, itest_node->deopt_infos().size()); | 1975 CHECK_EQ(0U, itest_node->deopt_infos().size()); |
1975 | 1976 |
1976 iprofiler->DeleteProfile(iprofile); | 1977 iprofiler->DeleteProfile(iprofile); |
1977 } | 1978 } |
OLD | NEW |