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

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

Issue 7040014: Remove redundant 'running' checks for ProfilerEventsProcessor in tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.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 // 2 //
3 // Tests of profiles generator and utilities. 3 // Tests of profiles generator and utilities.
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #include "v8.h" 7 #include "v8.h"
8 #include "cpu-profiler-inl.h" 8 #include "cpu-profiler-inl.h"
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "../include/v8-profiler.h" 10 #include "../include/v8-profiler.h"
11 11
12 namespace i = v8::internal; 12 namespace i = v8::internal;
13 13
14 using i::CodeEntry; 14 using i::CodeEntry;
15 using i::CpuProfile; 15 using i::CpuProfile;
16 using i::CpuProfiler; 16 using i::CpuProfiler;
17 using i::CpuProfilesCollection; 17 using i::CpuProfilesCollection;
18 using i::ProfileGenerator; 18 using i::ProfileGenerator;
19 using i::ProfileNode; 19 using i::ProfileNode;
20 using i::ProfilerEventsProcessor; 20 using i::ProfilerEventsProcessor;
21 using i::TokenEnumerator; 21 using i::TokenEnumerator;
22 22
23 23
24 TEST(StartStop) { 24 TEST(StartStop) {
25 CpuProfilesCollection profiles; 25 CpuProfilesCollection profiles;
26 ProfileGenerator generator(&profiles); 26 ProfileGenerator generator(&profiles);
27 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 27 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
28 processor.Start(); 28 processor.Start();
29 while (!processor.running()) {
30 i::Thread::YieldCPU();
31 }
32 processor.Stop(); 29 processor.Stop();
33 processor.Join(); 30 processor.Join();
34 } 31 }
35 32
36 static v8::Persistent<v8::Context> env; 33 static v8::Persistent<v8::Context> env;
37 34
38 static void InitializeVM() { 35 static void InitializeVM() {
39 if (env.IsEmpty()) env = v8::Context::New(); 36 if (env.IsEmpty()) env = v8::Context::New();
40 v8::HandleScope scope; 37 v8::HandleScope scope;
41 env->Enter(); 38 env->Enter();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } // namespace 80 } // namespace
84 81
85 TEST(CodeEvents) { 82 TEST(CodeEvents) {
86 InitializeVM(); 83 InitializeVM();
87 TestSetup test_setup; 84 TestSetup test_setup;
88 CpuProfilesCollection profiles; 85 CpuProfilesCollection profiles;
89 profiles.StartProfiling("", 1); 86 profiles.StartProfiling("", 1);
90 ProfileGenerator generator(&profiles); 87 ProfileGenerator generator(&profiles);
91 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 88 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
92 processor.Start(); 89 processor.Start();
93 while (!processor.running()) {
94 i::Thread::YieldCPU();
95 }
96 90
97 // Enqueue code creation events. 91 // Enqueue code creation events.
98 i::HandleScope scope; 92 i::HandleScope scope;
99 const char* aaa_str = "aaa"; 93 const char* aaa_str = "aaa";
100 i::Handle<i::String> aaa_name = FACTORY->NewStringFromAscii( 94 i::Handle<i::String> aaa_name = FACTORY->NewStringFromAscii(
101 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 95 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
102 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, 96 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG,
103 *aaa_name, 97 *aaa_name,
104 HEAP->empty_string(), 98 HEAP->empty_string(),
105 0, 99 0,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 141 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
148 } 142 }
149 143
150 TEST(TickEvents) { 144 TEST(TickEvents) {
151 TestSetup test_setup; 145 TestSetup test_setup;
152 CpuProfilesCollection profiles; 146 CpuProfilesCollection profiles;
153 profiles.StartProfiling("", 1); 147 profiles.StartProfiling("", 1);
154 ProfileGenerator generator(&profiles); 148 ProfileGenerator generator(&profiles);
155 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 149 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
156 processor.Start(); 150 processor.Start();
157 while (!processor.running()) {
158 i::Thread::YieldCPU();
159 }
160 151
161 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 152 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
162 "bbb", 153 "bbb",
163 ToAddress(0x1200), 154 ToAddress(0x1200),
164 0x80); 155 0x80);
165 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); 156 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
166 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 157 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
167 "ddd", 158 "ddd",
168 ToAddress(0x1400), 159 ToAddress(0x1400),
169 0x80); 160 0x80);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 231
241 // http://code.google.com/p/v8/issues/detail?id=1398 232 // http://code.google.com/p/v8/issues/detail?id=1398
242 // Long stacks (exceeding max frames limit) must not be erased. 233 // Long stacks (exceeding max frames limit) must not be erased.
243 TEST(Issue1398) { 234 TEST(Issue1398) {
244 TestSetup test_setup; 235 TestSetup test_setup;
245 CpuProfilesCollection profiles; 236 CpuProfilesCollection profiles;
246 profiles.StartProfiling("", 1); 237 profiles.StartProfiling("", 1);
247 ProfileGenerator generator(&profiles); 238 ProfileGenerator generator(&profiles);
248 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 239 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
249 processor.Start(); 240 processor.Start();
250 while (!processor.running()) {
251 i::Thread::YieldCPU();
252 }
253 241
254 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 242 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
255 "bbb", 243 "bbb",
256 ToAddress(0x1200), 244 ToAddress(0x1200),
257 0x80); 245 0x80);
258 246
259 i::TickSample* sample = processor.TickSampleEvent(); 247 i::TickSample* sample = processor.TickSampleEvent();
260 sample->pc = ToAddress(0x1200); 248 sample->pc = ToAddress(0x1200);
261 sample->tos = 0; 249 sample->tos = 0;
262 sample->frames_count = i::TickSample::kMaxFramesCount; 250 sample->frames_count = i::TickSample::kMaxFramesCount;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 const_cast<v8::CpuProfile*>(p2)->Delete(); 396 const_cast<v8::CpuProfile*>(p2)->Delete();
409 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 397 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
410 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 398 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
411 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 399 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
412 const_cast<v8::CpuProfile*>(p3)->Delete(); 400 const_cast<v8::CpuProfile*>(p3)->Delete();
413 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 401 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
414 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 402 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
415 } 403 }
416 404
417 #endif // ENABLE_LOGGING_AND_PROFILING 405 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « src/cpu-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698