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

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

Issue 14087016: Rollback of r13735 in 3.17 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.17
Patch Set: Created 7 years, 8 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/version.cc ('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 #include "v8.h" 5 #include "v8.h"
6 #include "cpu-profiler-inl.h" 6 #include "cpu-profiler-inl.h"
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "../include/v8-profiler.h" 8 #include "../include/v8-profiler.h"
9 9
10 using i::CodeEntry; 10 using i::CodeEntry;
11 using i::CpuProfile; 11 using i::CpuProfile;
12 using i::CpuProfiler; 12 using i::CpuProfiler;
13 using i::CpuProfilesCollection; 13 using i::CpuProfilesCollection;
14 using i::ProfileGenerator; 14 using i::ProfileGenerator;
15 using i::ProfileNode; 15 using i::ProfileNode;
16 using i::ProfilerEventsProcessor; 16 using i::ProfilerEventsProcessor;
17 using i::TokenEnumerator; 17 using i::TokenEnumerator;
18 18
19 19
20 TEST(StartStop) { 20 TEST(StartStop) {
21 CpuProfilesCollection profiles; 21 CpuProfilesCollection profiles;
22 ProfileGenerator generator(&profiles); 22 ProfileGenerator generator(&profiles);
23 ProfilerEventsProcessor processor(&generator, NULL, 100); 23 ProfilerEventsProcessor processor(&generator);
24 processor.Start(); 24 processor.Start();
25 processor.Stop(); 25 processor.Stop();
26 processor.Join(); 26 processor.Join();
27 } 27 }
28 28
29 static v8::Persistent<v8::Context> env; 29 static v8::Persistent<v8::Context> env;
30 30
31 static void InitializeVM() { 31 static void InitializeVM() {
32 if (env.IsEmpty()) env = v8::Context::New(); 32 if (env.IsEmpty()) env = v8::Context::New();
33 v8::HandleScope scope; 33 v8::HandleScope scope;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 TEST(CodeEvents) { 78 TEST(CodeEvents) {
79 InitializeVM(); 79 InitializeVM();
80 i::Isolate* isolate = i::Isolate::Current(); 80 i::Isolate* isolate = i::Isolate::Current();
81 i::Heap* heap = isolate->heap(); 81 i::Heap* heap = isolate->heap();
82 i::Factory* factory = isolate->factory(); 82 i::Factory* factory = isolate->factory();
83 TestSetup test_setup; 83 TestSetup test_setup;
84 CpuProfilesCollection profiles; 84 CpuProfilesCollection profiles;
85 profiles.StartProfiling("", 1); 85 profiles.StartProfiling("", 1);
86 ProfileGenerator generator(&profiles); 86 ProfileGenerator generator(&profiles);
87 ProfilerEventsProcessor processor(&generator, NULL, 100); 87 ProfilerEventsProcessor processor(&generator);
88 processor.Start(); 88 processor.Start();
89 89
90 // Enqueue code creation events. 90 // Enqueue code creation events.
91 i::HandleScope scope(isolate); 91 i::HandleScope scope(isolate);
92 const char* aaa_str = "aaa"; 92 const char* aaa_str = "aaa";
93 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( 93 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
94 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 94 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
95 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, 95 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG,
96 *aaa_name, 96 *aaa_name,
97 heap->empty_string(), 97 heap->empty_string(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 template<typename T> 138 template<typename T>
139 static int CompareProfileNodes(const T* p1, const T* p2) { 139 static int CompareProfileNodes(const T* p1, const T* p2) {
140 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 140 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
141 } 141 }
142 142
143 TEST(TickEvents) { 143 TEST(TickEvents) {
144 TestSetup test_setup; 144 TestSetup test_setup;
145 CpuProfilesCollection profiles; 145 CpuProfilesCollection profiles;
146 profiles.StartProfiling("", 1); 146 profiles.StartProfiling("", 1);
147 ProfileGenerator generator(&profiles); 147 ProfileGenerator generator(&profiles);
148 ProfilerEventsProcessor processor(&generator, NULL, 100); 148 ProfilerEventsProcessor processor(&generator);
149 processor.Start(); 149 processor.Start();
150 150
151 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 151 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
152 "bbb", 152 "bbb",
153 ToAddress(0x1200), 153 ToAddress(0x1200),
154 0x80); 154 0x80);
155 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); 155 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
156 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 156 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
157 "ddd", 157 "ddd",
158 ToAddress(0x1400), 158 ToAddress(0x1400),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 230
231 // http://code.google.com/p/v8/issues/detail?id=1398 231 // http://code.google.com/p/v8/issues/detail?id=1398
232 // Long stacks (exceeding max frames limit) must not be erased. 232 // Long stacks (exceeding max frames limit) must not be erased.
233 TEST(Issue1398) { 233 TEST(Issue1398) {
234 TestSetup test_setup; 234 TestSetup test_setup;
235 CpuProfilesCollection profiles; 235 CpuProfilesCollection profiles;
236 profiles.StartProfiling("", 1); 236 profiles.StartProfiling("", 1);
237 ProfileGenerator generator(&profiles); 237 ProfileGenerator generator(&profiles);
238 ProfilerEventsProcessor processor(&generator, NULL, 100); 238 ProfilerEventsProcessor processor(&generator);
239 processor.Start(); 239 processor.Start();
240 240
241 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 241 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
242 "bbb", 242 "bbb",
243 ToAddress(0x1200), 243 ToAddress(0x1200),
244 0x80); 244 0x80);
245 245
246 i::TickSample* sample = processor.TickSampleEvent(); 246 i::TickSample* sample = processor.TickSampleEvent();
247 sample->pc = ToAddress(0x1200); 247 sample->pc = ToAddress(0x1200);
248 sample->tos = 0; 248 sample->tos = 0;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 393 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
394 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 394 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
395 const_cast<v8::CpuProfile*>(p2)->Delete(); 395 const_cast<v8::CpuProfile*>(p2)->Delete();
396 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); 396 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
397 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); 397 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
398 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); 398 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
399 const_cast<v8::CpuProfile*>(p3)->Delete(); 399 const_cast<v8::CpuProfile*>(p3)->Delete();
400 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); 400 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
401 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); 401 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
402 } 402 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698