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

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

Issue 23690003: Revert "Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « test/cctest/cctest.gyp ('k') | test/cctest/test-time.cc » ('j') | 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 26 matching lines...) Expand all
37 using i::CodeEntry; 37 using i::CodeEntry;
38 using i::CpuProfile; 38 using i::CpuProfile;
39 using i::CpuProfiler; 39 using i::CpuProfiler;
40 using i::CpuProfilesCollection; 40 using i::CpuProfilesCollection;
41 using i::Heap; 41 using i::Heap;
42 using i::ProfileGenerator; 42 using i::ProfileGenerator;
43 using i::ProfileNode; 43 using i::ProfileNode;
44 using i::ProfilerEventsProcessor; 44 using i::ProfilerEventsProcessor;
45 using i::ScopedVector; 45 using i::ScopedVector;
46 using i::SmartPointer; 46 using i::SmartPointer;
47 using i::TimeDelta;
48 using i::Vector; 47 using i::Vector;
49 48
50 49
51 TEST(StartStop) { 50 TEST(StartStop) {
52 CpuProfilesCollection profiles; 51 CpuProfilesCollection profiles;
53 ProfileGenerator generator(&profiles); 52 ProfileGenerator generator(&profiles);
54 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 53 SmartPointer<ProfilerEventsProcessor> processor(
55 &generator, NULL, TimeDelta::FromMicroseconds(100))); 54 new ProfilerEventsProcessor(&generator, NULL, 100));
56 processor->Start(); 55 processor->Start();
57 processor->StopSynchronously(); 56 processor->StopSynchronously();
58 } 57 }
59 58
60 59
61 static inline i::Address ToAddress(int n) { 60 static inline i::Address ToAddress(int n) {
62 return reinterpret_cast<i::Address>(n); 61 return reinterpret_cast<i::Address>(n);
63 } 62 }
64 63
65 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 64 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 i::Code* comment_code = CreateCode(&env); 135 i::Code* comment_code = CreateCode(&env);
137 i::Code* args5_code = CreateCode(&env); 136 i::Code* args5_code = CreateCode(&env);
138 i::Code* comment2_code = CreateCode(&env); 137 i::Code* comment2_code = CreateCode(&env);
139 i::Code* moved_code = CreateCode(&env); 138 i::Code* moved_code = CreateCode(&env);
140 i::Code* args3_code = CreateCode(&env); 139 i::Code* args3_code = CreateCode(&env);
141 i::Code* args4_code = CreateCode(&env); 140 i::Code* args4_code = CreateCode(&env);
142 141
143 CpuProfilesCollection* profiles = new CpuProfilesCollection; 142 CpuProfilesCollection* profiles = new CpuProfilesCollection;
144 profiles->StartProfiling("", 1, false); 143 profiles->StartProfiling("", 1, false);
145 ProfileGenerator generator(profiles); 144 ProfileGenerator generator(profiles);
146 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 145 SmartPointer<ProfilerEventsProcessor> processor(
147 &generator, NULL, TimeDelta::FromMicroseconds(100))); 146 new ProfilerEventsProcessor(&generator, NULL, 100));
148 processor->Start(); 147 processor->Start();
149 CpuProfiler profiler(isolate, profiles, &generator, *processor); 148 CpuProfiler profiler(isolate, profiles, &generator, *processor);
150 149
151 // Enqueue code creation events. 150 // Enqueue code creation events.
152 const char* aaa_str = "aaa"; 151 const char* aaa_str = "aaa";
153 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( 152 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
154 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 153 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
155 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name); 154 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name);
156 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); 155 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment");
157 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); 156 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 i::Isolate* isolate = i::Isolate::Current(); 197 i::Isolate* isolate = i::Isolate::Current();
199 i::HandleScope scope(isolate); 198 i::HandleScope scope(isolate);
200 199
201 i::Code* frame1_code = CreateCode(&env); 200 i::Code* frame1_code = CreateCode(&env);
202 i::Code* frame2_code = CreateCode(&env); 201 i::Code* frame2_code = CreateCode(&env);
203 i::Code* frame3_code = CreateCode(&env); 202 i::Code* frame3_code = CreateCode(&env);
204 203
205 CpuProfilesCollection* profiles = new CpuProfilesCollection; 204 CpuProfilesCollection* profiles = new CpuProfilesCollection;
206 profiles->StartProfiling("", 1, false); 205 profiles->StartProfiling("", 1, false);
207 ProfileGenerator generator(profiles); 206 ProfileGenerator generator(profiles);
208 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 207 SmartPointer<ProfilerEventsProcessor> processor(
209 &generator, NULL, TimeDelta::FromMicroseconds(100))); 208 new ProfilerEventsProcessor(&generator, NULL, 100));
210 processor->Start(); 209 processor->Start();
211 CpuProfiler profiler(isolate, profiles, &generator, *processor); 210 CpuProfiler profiler(isolate, profiles, &generator, *processor);
212 211
213 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); 212 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb");
214 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); 213 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5);
215 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); 214 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd");
216 215
217 EnqueueTickSampleEvent(*processor, frame1_code->instruction_start()); 216 EnqueueTickSampleEvent(*processor, frame1_code->instruction_start());
218 EnqueueTickSampleEvent( 217 EnqueueTickSampleEvent(
219 *processor, 218 *processor,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 TestSetup test_setup; 266 TestSetup test_setup;
268 LocalContext env; 267 LocalContext env;
269 i::Isolate* isolate = i::Isolate::Current(); 268 i::Isolate* isolate = i::Isolate::Current();
270 i::HandleScope scope(isolate); 269 i::HandleScope scope(isolate);
271 270
272 i::Code* code = CreateCode(&env); 271 i::Code* code = CreateCode(&env);
273 272
274 CpuProfilesCollection* profiles = new CpuProfilesCollection; 273 CpuProfilesCollection* profiles = new CpuProfilesCollection;
275 profiles->StartProfiling("", 1, false); 274 profiles->StartProfiling("", 1, false);
276 ProfileGenerator generator(profiles); 275 ProfileGenerator generator(profiles);
277 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 276 SmartPointer<ProfilerEventsProcessor> processor(
278 &generator, NULL, TimeDelta::FromMicroseconds(100))); 277 new ProfilerEventsProcessor(&generator, NULL, 100));
279 processor->Start(); 278 processor->Start();
280 CpuProfiler profiler(isolate, profiles, &generator, *processor); 279 CpuProfiler profiler(isolate, profiles, &generator, *processor);
281 280
282 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 281 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
283 282
284 i::TickSample* sample = processor->StartTickSample(); 283 i::TickSample* sample = processor->StartTickSample();
285 sample->pc = code->address(); 284 sample->pc = code->address();
286 sample->tos = 0; 285 sample->tos = 0;
287 sample->frames_count = i::TickSample::kMaxFramesCount; 286 sample->frames_count = i::TickSample::kMaxFramesCount;
288 for (int i = 0; i < sample->frames_count; ++i) { 287 for (int i = 0; i < sample->frames_count; ++i) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 isolate->Dispose(); 412 isolate->Dispose();
414 CHECK_EQ(NULL, isolate->GetCpuProfiler()); 413 CHECK_EQ(NULL, isolate->GetCpuProfiler());
415 } 414 }
416 415
417 416
418 TEST(ProfileStartEndTime) { 417 TEST(ProfileStartEndTime) {
419 LocalContext env; 418 LocalContext env;
420 v8::HandleScope scope(env->GetIsolate()); 419 v8::HandleScope scope(env->GetIsolate());
421 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 420 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
422 421
422 int64_t time_before_profiling = i::OS::Ticks();
423 v8::Local<v8::String> profile_name = v8::String::New("test"); 423 v8::Local<v8::String> profile_name = v8::String::New("test");
424 cpu_profiler->StartCpuProfiling(profile_name); 424 cpu_profiler->StartCpuProfiling(profile_name);
425 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); 425 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
426 CHECK(time_before_profiling <= profile->GetStartTime());
426 CHECK(profile->GetStartTime() <= profile->GetEndTime()); 427 CHECK(profile->GetStartTime() <= profile->GetEndTime());
428 CHECK(profile->GetEndTime() <= i::OS::Ticks());
427 } 429 }
428 430
429 431
430 static const v8::CpuProfile* RunProfiler( 432 static const v8::CpuProfile* RunProfiler(
431 LocalContext& env, v8::Handle<v8::Function> function, 433 LocalContext& env, v8::Handle<v8::Function> function,
432 v8::Handle<v8::Value> argv[], int argc, 434 v8::Handle<v8::Value> argv[], int argc,
433 unsigned min_js_samples) { 435 unsigned min_js_samples) {
434 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 436 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
435 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); 437 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
436 438
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 CHECK_EQ(0, programNode->GetChildrenCount()); 1374 CHECK_EQ(0, programNode->GetChildrenCount());
1373 CHECK_GE(programNode->GetHitCount(), 3); 1375 CHECK_GE(programNode->GetHitCount(), 3);
1374 1376
1375 const v8::CpuProfileNode* idleNode = 1377 const v8::CpuProfileNode* idleNode =
1376 GetChild(root, ProfileGenerator::kIdleEntryName); 1378 GetChild(root, ProfileGenerator::kIdleEntryName);
1377 CHECK_EQ(0, idleNode->GetChildrenCount()); 1379 CHECK_EQ(0, idleNode->GetChildrenCount());
1378 CHECK_GE(idleNode->GetHitCount(), 3); 1380 CHECK_GE(idleNode->GetHitCount(), 3);
1379 1381
1380 cpu_profiler->DeleteAllCpuProfiles(); 1382 cpu_profiler->DeleteAllCpuProfiles();
1381 } 1383 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698