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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 2108393002: Split Ticker into two samplers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/profiler/cpu-profiler-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 static const char* reason(const i::Deoptimizer::DeoptReason reason) { 66 static const char* reason(const i::Deoptimizer::DeoptReason reason) {
67 return i::Deoptimizer::GetDeoptReason(reason); 67 return i::Deoptimizer::GetDeoptReason(reason);
68 } 68 }
69 69
70 TEST(StartStop) { 70 TEST(StartStop) {
71 CpuProfilesCollection profiles(CcTest::i_isolate()); 71 CpuProfilesCollection profiles(CcTest::i_isolate());
72 ProfileGenerator generator(&profiles); 72 ProfileGenerator generator(&profiles);
73 std::unique_ptr<ProfilerEventsProcessor> processor( 73 std::unique_ptr<ProfilerEventsProcessor> processor(
74 new ProfilerEventsProcessor(&generator, nullptr, 74 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator,
75 v8::base::TimeDelta::FromMicroseconds(100))); 75 v8::base::TimeDelta::FromMicroseconds(100)));
76 processor->Start(); 76 processor->Start();
77 processor->StopSynchronously(); 77 processor->StopSynchronously();
78 } 78 }
79 79
80 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 80 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
81 i::Address frame1, 81 i::Address frame1,
82 i::Address frame2 = NULL, 82 i::Address frame2 = NULL,
83 i::Address frame3 = NULL) { 83 i::Address frame3 = NULL) {
84 i::TickSample* sample = proc->StartTickSample(); 84 i::TickSample* sample = proc->StartTickSample();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 i::AbstractCode* aaa_code = CreateCode(&env); 148 i::AbstractCode* aaa_code = CreateCode(&env);
149 i::AbstractCode* comment_code = CreateCode(&env); 149 i::AbstractCode* comment_code = CreateCode(&env);
150 i::AbstractCode* args5_code = CreateCode(&env); 150 i::AbstractCode* args5_code = CreateCode(&env);
151 i::AbstractCode* comment2_code = CreateCode(&env); 151 i::AbstractCode* comment2_code = CreateCode(&env);
152 i::AbstractCode* moved_code = CreateCode(&env); 152 i::AbstractCode* moved_code = CreateCode(&env);
153 i::AbstractCode* args3_code = CreateCode(&env); 153 i::AbstractCode* args3_code = CreateCode(&env);
154 i::AbstractCode* args4_code = CreateCode(&env); 154 i::AbstractCode* args4_code = CreateCode(&env);
155 155
156 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 156 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
157 ProfileGenerator* generator = new ProfileGenerator(profiles); 157 ProfileGenerator* generator = new ProfileGenerator(profiles);
158 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 158 ProfilerEventsProcessor* processor =
159 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 159 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
160 v8::base::TimeDelta::FromMicroseconds(100));
160 CpuProfiler profiler(isolate, profiles, generator, processor); 161 CpuProfiler profiler(isolate, profiles, generator, processor);
161 profiles->StartProfiling("", false); 162 profiles->StartProfiling("", false);
162 processor->Start(); 163 processor->Start();
163 ProfilerListener profiler_listener(isolate); 164 ProfilerListener profiler_listener(isolate);
164 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 165 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
165 profiler_listener.AddObserver(&profiler); 166 profiler_listener.AddObserver(&profiler);
166 167
167 // Enqueue code creation events. 168 // Enqueue code creation events.
168 const char* aaa_str = "aaa"; 169 const char* aaa_str = "aaa";
169 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str); 170 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 LocalContext env; 217 LocalContext env;
217 i::Isolate* isolate = CcTest::i_isolate(); 218 i::Isolate* isolate = CcTest::i_isolate();
218 i::HandleScope scope(isolate); 219 i::HandleScope scope(isolate);
219 220
220 i::AbstractCode* frame1_code = CreateCode(&env); 221 i::AbstractCode* frame1_code = CreateCode(&env);
221 i::AbstractCode* frame2_code = CreateCode(&env); 222 i::AbstractCode* frame2_code = CreateCode(&env);
222 i::AbstractCode* frame3_code = CreateCode(&env); 223 i::AbstractCode* frame3_code = CreateCode(&env);
223 224
224 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 225 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
225 ProfileGenerator* generator = new ProfileGenerator(profiles); 226 ProfileGenerator* generator = new ProfileGenerator(profiles);
226 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 227 ProfilerEventsProcessor* processor =
227 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 228 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
229 v8::base::TimeDelta::FromMicroseconds(100));
228 CpuProfiler profiler(isolate, profiles, generator, processor); 230 CpuProfiler profiler(isolate, profiles, generator, processor);
229 profiles->StartProfiling("", false); 231 profiles->StartProfiling("", false);
230 processor->Start(); 232 processor->Start();
231 ProfilerListener profiler_listener(isolate); 233 ProfilerListener profiler_listener(isolate);
232 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 234 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
233 profiler_listener.AddObserver(&profiler); 235 profiler_listener.AddObserver(&profiler);
234 236
235 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); 237 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb");
236 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); 238 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5);
237 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); 239 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 TEST(Issue1398) { 290 TEST(Issue1398) {
289 TestSetup test_setup; 291 TestSetup test_setup;
290 LocalContext env; 292 LocalContext env;
291 i::Isolate* isolate = CcTest::i_isolate(); 293 i::Isolate* isolate = CcTest::i_isolate();
292 i::HandleScope scope(isolate); 294 i::HandleScope scope(isolate);
293 295
294 i::AbstractCode* code = CreateCode(&env); 296 i::AbstractCode* code = CreateCode(&env);
295 297
296 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 298 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
297 ProfileGenerator* generator = new ProfileGenerator(profiles); 299 ProfileGenerator* generator = new ProfileGenerator(profiles);
298 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 300 ProfilerEventsProcessor* processor =
299 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 301 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
302 v8::base::TimeDelta::FromMicroseconds(100));
300 CpuProfiler profiler(isolate, profiles, generator, processor); 303 CpuProfiler profiler(isolate, profiles, generator, processor);
301 profiles->StartProfiling("", false); 304 profiles->StartProfiling("", false);
302 processor->Start(); 305 processor->Start();
303 ProfilerListener profiler_listener(isolate); 306 ProfilerListener profiler_listener(isolate);
304 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 307 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
305 profiler_listener.AddObserver(&profiler); 308 profiler_listener.AddObserver(&profiler);
306 309
307 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 310 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
308 311
309 i::TickSample* sample = processor->StartTickSample(); 312 i::TickSample* sample = processor->StartTickSample();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 v8::Local<v8::Value> argv[], int argc, 433 v8::Local<v8::Value> argv[], int argc,
431 unsigned min_js_samples = 0, 434 unsigned min_js_samples = 0,
432 unsigned min_external_samples = 0, 435 unsigned min_external_samples = 0,
433 bool collect_samples = false) { 436 bool collect_samples = false) {
434 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 437 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
435 v8::Local<v8::String> profile_name = v8_str("my_profile"); 438 v8::Local<v8::String> profile_name = v8_str("my_profile");
436 439
437 cpu_profiler->SetSamplingInterval(100); 440 cpu_profiler->SetSamplingInterval(100);
438 cpu_profiler->StartProfiling(profile_name, collect_samples); 441 cpu_profiler->StartProfiling(profile_name, collect_samples);
439 442
440 v8::sampler::Sampler* sampler = 443 v8::internal::CpuProfiler* i_cpu_profiler =
441 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); 444 reinterpret_cast<v8::internal::CpuProfiler*>(cpu_profiler);
445 v8::sampler::Sampler* sampler = i_cpu_profiler->processor()->sampler();
442 sampler->StartCountingSamples(); 446 sampler->StartCountingSamples();
443 do { 447 do {
444 function->Call(env, env->Global(), argc, argv).ToLocalChecked(); 448 function->Call(env, env->Global(), argc, argv).ToLocalChecked();
445 } while (sampler->js_sample_count() < min_js_samples || 449 } while (sampler->js_sample_count() < min_js_samples ||
446 sampler->external_sample_count() < min_external_samples); 450 sampler->external_sample_count() < min_external_samples);
447 451
448 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); 452 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name);
449 453
450 CHECK(profile); 454 CHECK(profile);
451 // Dump collected profile to have a better diagnostic in case of failure. 455 // Dump collected profile to have a better diagnostic in case of failure.
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 v8::Utils::OpenHandle(*GetFunction(env.local(), func_name))); 1035 v8::Utils::OpenHandle(*GetFunction(env.local(), func_name)));
1032 CHECK(func->shared()); 1036 CHECK(func->shared());
1033 CHECK(func->shared()->abstract_code()); 1037 CHECK(func->shared()->abstract_code());
1034 i::AbstractCode* code = func->abstract_code(); 1038 i::AbstractCode* code = func->abstract_code();
1035 CHECK(code); 1039 CHECK(code);
1036 i::Address code_address = code->instruction_start(); 1040 i::Address code_address = code->instruction_start();
1037 CHECK(code_address); 1041 CHECK(code_address);
1038 1042
1039 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 1043 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
1040 ProfileGenerator* generator = new ProfileGenerator(profiles); 1044 ProfileGenerator* generator = new ProfileGenerator(profiles);
1041 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 1045 ProfilerEventsProcessor* processor =
1042 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 1046 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
1047 v8::base::TimeDelta::FromMicroseconds(100));
1043 CpuProfiler profiler(isolate, profiles, generator, processor); 1048 CpuProfiler profiler(isolate, profiles, generator, processor);
1044 profiles->StartProfiling("", false); 1049 profiles->StartProfiling("", false);
1045 processor->Start(); 1050 processor->Start();
1046 ProfilerListener profiler_listener(isolate); 1051 ProfilerListener profiler_listener(isolate);
1047 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 1052 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
1048 profiler_listener.AddObserver(&profiler); 1053 profiler_listener.AddObserver(&profiler);
1049 1054
1050 // Enqueue code creation events. 1055 // Enqueue code creation events.
1051 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name); 1056 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name);
1052 int line = 1; 1057 int line = 1;
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 iprofile->Print(); 2048 iprofile->Print();
2044 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 2049 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
2045 2050
2046 const char* branch[] = {"", "test"}; 2051 const char* branch[] = {"", "test"};
2047 const ProfileNode* itest_node = 2052 const ProfileNode* itest_node =
2048 GetSimpleBranch(env, profile, branch, arraysize(branch)); 2053 GetSimpleBranch(env, profile, branch, arraysize(branch));
2049 CHECK_EQ(0U, itest_node->deopt_infos().size()); 2054 CHECK_EQ(0U, itest_node->deopt_infos().size());
2050 2055
2051 iprofiler->DeleteProfile(iprofile); 2056 iprofiler->DeleteProfile(iprofile);
2052 } 2057 }
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698