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

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

Issue 7003108: "Deiceolate" Thread classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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
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(&generator);
28 processor.Start(); 28 processor.Start();
29 processor.Stop(); 29 processor.Stop();
30 processor.Join(); 30 processor.Join();
31 } 31 }
32 32
33 static v8::Persistent<v8::Context> env; 33 static v8::Persistent<v8::Context> env;
34 34
35 static void InitializeVM() { 35 static void InitializeVM() {
36 if (env.IsEmpty()) env = v8::Context::New(); 36 if (env.IsEmpty()) env = v8::Context::New();
37 v8::HandleScope scope; 37 v8::HandleScope scope;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 78 };
79 79
80 } // namespace 80 } // namespace
81 81
82 TEST(CodeEvents) { 82 TEST(CodeEvents) {
83 InitializeVM(); 83 InitializeVM();
84 TestSetup test_setup; 84 TestSetup test_setup;
85 CpuProfilesCollection profiles; 85 CpuProfilesCollection profiles;
86 profiles.StartProfiling("", 1); 86 profiles.StartProfiling("", 1);
87 ProfileGenerator generator(&profiles); 87 ProfileGenerator generator(&profiles);
88 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 88 ProfilerEventsProcessor processor(&generator);
89 processor.Start(); 89 processor.Start();
90 90
91 // Enqueue code creation events. 91 // Enqueue code creation events.
92 i::HandleScope scope; 92 i::HandleScope scope;
93 const char* aaa_str = "aaa"; 93 const char* aaa_str = "aaa";
94 i::Handle<i::String> aaa_name = FACTORY->NewStringFromAscii( 94 i::Handle<i::String> aaa_name = FACTORY->NewStringFromAscii(
95 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 95 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
96 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, 96 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG,
97 *aaa_name, 97 *aaa_name,
98 HEAP->empty_string(), 98 HEAP->empty_string(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 template<typename T> 139 template<typename T>
140 static int CompareProfileNodes(const T* p1, const T* p2) { 140 static int CompareProfileNodes(const T* p1, const T* p2) {
141 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 141 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
142 } 142 }
143 143
144 TEST(TickEvents) { 144 TEST(TickEvents) {
145 TestSetup test_setup; 145 TestSetup test_setup;
146 CpuProfilesCollection profiles; 146 CpuProfilesCollection profiles;
147 profiles.StartProfiling("", 1); 147 profiles.StartProfiling("", 1);
148 ProfileGenerator generator(&profiles); 148 ProfileGenerator generator(&profiles);
149 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 149 ProfilerEventsProcessor processor(&generator);
150 processor.Start(); 150 processor.Start();
151 151
152 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 152 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
153 "bbb", 153 "bbb",
154 ToAddress(0x1200), 154 ToAddress(0x1200),
155 0x80); 155 0x80);
156 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); 156 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
157 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 157 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
158 "ddd", 158 "ddd",
159 ToAddress(0x1400), 159 ToAddress(0x1400),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 230
231 231
232 // http://code.google.com/p/v8/issues/detail?id=1398 232 // http://code.google.com/p/v8/issues/detail?id=1398
233 // Long stacks (exceeding max frames limit) must not be erased. 233 // Long stacks (exceeding max frames limit) must not be erased.
234 TEST(Issue1398) { 234 TEST(Issue1398) {
235 TestSetup test_setup; 235 TestSetup test_setup;
236 CpuProfilesCollection profiles; 236 CpuProfilesCollection profiles;
237 profiles.StartProfiling("", 1); 237 profiles.StartProfiling("", 1);
238 ProfileGenerator generator(&profiles); 238 ProfileGenerator generator(&profiles);
239 ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); 239 ProfilerEventsProcessor processor(&generator);
240 processor.Start(); 240 processor.Start();
241 241
242 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 242 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
243 "bbb", 243 "bbb",
244 ToAddress(0x1200), 244 ToAddress(0x1200),
245 0x80); 245 0x80);
246 246
247 i::TickSample* sample = processor.TickSampleEvent(); 247 i::TickSample* sample = processor.TickSampleEvent();
248 sample->pc = ToAddress(0x1200); 248 sample->pc = ToAddress(0x1200);
249 sample->tos = 0; 249 sample->tos = 0;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 const_cast<v8::CpuProfile*>(p2)->Delete(); 396 const_cast<v8::CpuProfile*>(p2)->Delete();
397 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 397 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
398 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 398 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
399 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 399 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
400 const_cast<v8::CpuProfile*>(p3)->Delete(); 400 const_cast<v8::CpuProfile*>(p3)->Delete();
401 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 401 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
402 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 402 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
403 } 403 }
404 404
405 #endif // ENABLE_LOGGING_AND_PROFILING 405 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698