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: src/profile-generator.cc

Issue 13454002: Allow recording individual samples in addition to the aggregated CPU profiles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase 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/profile-generator.h ('k') | src/profile-generator-inl.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }; 289 };
290 290
291 291
292 ProfileTree::ProfileTree() 292 ProfileTree::ProfileTree()
293 : root_entry_(Logger::FUNCTION_TAG, 293 : root_entry_(Logger::FUNCTION_TAG,
294 "", 294 "",
295 "(root)", 295 "(root)",
296 "", 296 "",
297 0, 297 0,
298 TokenEnumerator::kNoSecurityToken), 298 TokenEnumerator::kNoSecurityToken),
299 next_node_id_(1),
299 root_(new ProfileNode(this, &root_entry_)) { 300 root_(new ProfileNode(this, &root_entry_)) {
300 } 301 }
301 302
302 303
303 ProfileTree::~ProfileTree() { 304 ProfileTree::~ProfileTree() {
304 DeleteNodesCallback cb; 305 DeleteNodesCallback cb;
305 TraverseDepthFirst(&cb); 306 TraverseDepthFirst(&cb);
306 } 307 }
307 308
308 309
309 void ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) { 310 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
310 ProfileNode* node = root_; 311 ProfileNode* node = root_;
311 for (CodeEntry** entry = path.start() + path.length() - 1; 312 for (CodeEntry** entry = path.start() + path.length() - 1;
312 entry != path.start() - 1; 313 entry != path.start() - 1;
313 --entry) { 314 --entry) {
314 if (*entry != NULL) { 315 if (*entry != NULL) {
315 node = node->FindOrAddChild(*entry); 316 node = node->FindOrAddChild(*entry);
316 } 317 }
317 } 318 }
318 node->IncrementSelfTicks(); 319 node->IncrementSelfTicks();
320 return node;
319 } 321 }
320 322
321 323
322 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) { 324 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
323 ProfileNode* node = root_; 325 ProfileNode* node = root_;
324 for (CodeEntry** entry = path.start(); 326 for (CodeEntry** entry = path.start();
325 entry != path.start() + path.length(); 327 entry != path.start() + path.length();
326 ++entry) { 328 ++entry) {
327 if (*entry != NULL) { 329 if (*entry != NULL) {
328 node = node->FindOrAddChild(*entry); 330 node = node->FindOrAddChild(*entry);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 462
461 463
462 void ProfileTree::ShortPrint() { 464 void ProfileTree::ShortPrint() {
463 OS::Print("root: %u %u %.2fms %.2fms\n", 465 OS::Print("root: %u %u %.2fms %.2fms\n",
464 root_->total_ticks(), root_->self_ticks(), 466 root_->total_ticks(), root_->self_ticks(),
465 root_->GetTotalMillis(), root_->GetSelfMillis()); 467 root_->GetTotalMillis(), root_->GetSelfMillis());
466 } 468 }
467 469
468 470
469 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { 471 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
470 top_down_.AddPathFromEnd(path); 472 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path);
473 if (record_samples_) samples_.Add(top_frame_node);
471 } 474 }
472 475
473 476
474 void CpuProfile::CalculateTotalTicks() { 477 void CpuProfile::CalculateTotalTicks() {
475 top_down_.CalculateTotalTicks(); 478 top_down_.CalculateTotalTicks();
476 } 479 }
477 480
478 481
479 void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) { 482 void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
480 top_down_.SetTickRatePerMs(actual_sampling_rate); 483 top_down_.SetTickRatePerMs(actual_sampling_rate);
481 } 484 }
482 485
483 486
484 CpuProfile* CpuProfile::FilteredClone(int security_token_id) { 487 CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
485 ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken); 488 ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
486 CpuProfile* clone = new CpuProfile(title_, uid_); 489 CpuProfile* clone = new CpuProfile(title_, uid_, false);
487 clone->top_down_.FilteredClone(&top_down_, security_token_id); 490 clone->top_down_.FilteredClone(&top_down_, security_token_id);
488 return clone; 491 return clone;
489 } 492 }
490 493
491 494
492 void CpuProfile::ShortPrint() { 495 void CpuProfile::ShortPrint() {
493 OS::Print("top down "); 496 OS::Print("top down ");
494 top_down_.ShortPrint(); 497 top_down_.ShortPrint();
495 } 498 }
496 499
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 605
603 CpuProfilesCollection::~CpuProfilesCollection() { 606 CpuProfilesCollection::~CpuProfilesCollection() {
604 delete current_profiles_semaphore_; 607 delete current_profiles_semaphore_;
605 current_profiles_.Iterate(DeleteCpuProfile); 608 current_profiles_.Iterate(DeleteCpuProfile);
606 detached_profiles_.Iterate(DeleteCpuProfile); 609 detached_profiles_.Iterate(DeleteCpuProfile);
607 profiles_by_token_.Iterate(DeleteProfilesList); 610 profiles_by_token_.Iterate(DeleteProfilesList);
608 code_entries_.Iterate(DeleteCodeEntry); 611 code_entries_.Iterate(DeleteCodeEntry);
609 } 612 }
610 613
611 614
612 bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid) { 615 bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid,
616 bool record_samples) {
613 ASSERT(uid > 0); 617 ASSERT(uid > 0);
614 current_profiles_semaphore_->Wait(); 618 current_profiles_semaphore_->Wait();
615 if (current_profiles_.length() >= kMaxSimultaneousProfiles) { 619 if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
616 current_profiles_semaphore_->Signal(); 620 current_profiles_semaphore_->Signal();
617 return false; 621 return false;
618 } 622 }
619 for (int i = 0; i < current_profiles_.length(); ++i) { 623 for (int i = 0; i < current_profiles_.length(); ++i) {
620 if (strcmp(current_profiles_[i]->title(), title) == 0) { 624 if (strcmp(current_profiles_[i]->title(), title) == 0) {
621 // Ignore attempts to start profile with the same title. 625 // Ignore attempts to start profile with the same title.
622 current_profiles_semaphore_->Signal(); 626 current_profiles_semaphore_->Signal();
623 return false; 627 return false;
624 } 628 }
625 } 629 }
626 current_profiles_.Add(new CpuProfile(title, uid)); 630 current_profiles_.Add(new CpuProfile(title, uid, record_samples));
627 current_profiles_semaphore_->Signal(); 631 current_profiles_semaphore_->Signal();
628 return true; 632 return true;
629 } 633 }
630 634
631 635
632 bool CpuProfilesCollection::StartProfiling(String* title, unsigned uid) {
633 return StartProfiling(GetName(title), uid);
634 }
635
636
637 CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id, 636 CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
638 const char* title, 637 const char* title,
639 double actual_sampling_rate) { 638 double actual_sampling_rate) {
640 const int title_len = StrLength(title); 639 const int title_len = StrLength(title);
641 CpuProfile* profile = NULL; 640 CpuProfile* profile = NULL;
642 current_profiles_semaphore_->Wait(); 641 current_profiles_semaphore_->Wait();
643 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 642 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
644 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) { 643 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) {
645 profile = current_profiles_.Remove(i); 644 profile = current_profiles_.Remove(i);
646 break; 645 break;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 if (no_symbolized_entries) { 930 if (no_symbolized_entries) {
932 *entry++ = EntryForVMState(sample.state); 931 *entry++ = EntryForVMState(sample.state);
933 } 932 }
934 } 933 }
935 934
936 profiles_->AddPathToCurrentProfiles(entries); 935 profiles_->AddPathToCurrentProfiles(entries);
937 } 936 }
938 937
939 938
940 } } // namespace v8::internal 939 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/profile-generator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698