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

Side by Side Diff: src/profile-generator.cc

Issue 21173004: Version 3.20.11.1 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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/runtime.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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 365 }
366 366
367 367
368 void ProfileTree::ShortPrint() { 368 void ProfileTree::ShortPrint() {
369 OS::Print("root: %u %u %.2fms %.2fms\n", 369 OS::Print("root: %u %u %.2fms %.2fms\n",
370 root_->total_ticks(), root_->self_ticks(), 370 root_->total_ticks(), root_->self_ticks(),
371 root_->GetTotalMillis(), root_->GetSelfMillis()); 371 root_->GetTotalMillis(), root_->GetSelfMillis());
372 } 372 }
373 373
374 374
375 CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples)
376 : title_(title),
377 uid_(uid),
378 record_samples_(record_samples),
379 start_time_ms_(OS::TimeCurrentMillis()),
380 end_time_ms_(0) {
381 }
382
383
384 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { 375 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
385 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); 376 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path);
386 if (record_samples_) samples_.Add(top_frame_node); 377 if (record_samples_) samples_.Add(top_frame_node);
387 } 378 }
388 379
389 380
390 void CpuProfile::CalculateTotalTicksAndSamplingRate() { 381 void CpuProfile::CalculateTotalTicks() {
391 end_time_ms_ = OS::TimeCurrentMillis();
392 top_down_.CalculateTotalTicks(); 382 top_down_.CalculateTotalTicks();
393
394 double duration = end_time_ms_ - start_time_ms_;
395 if (duration < 1) duration = 1;
396 unsigned ticks = top_down_.root()->total_ticks();
397 double rate = ticks / duration;
398 top_down_.SetTickRatePerMs(rate);
399 } 383 }
400 384
401 385
386 void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
387 top_down_.SetTickRatePerMs(actual_sampling_rate);
388 }
389
390
402 void CpuProfile::ShortPrint() { 391 void CpuProfile::ShortPrint() {
403 OS::Print("top down "); 392 OS::Print("top down ");
404 top_down_.ShortPrint(); 393 top_down_.ShortPrint();
405 } 394 }
406 395
407 396
408 void CpuProfile::Print() { 397 void CpuProfile::Print() {
409 OS::Print("[Top down]:\n"); 398 OS::Print("[Top down]:\n");
410 top_down_.Print(); 399 top_down_.Print();
411 } 400 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 current_profiles_semaphore_->Signal(); 522 current_profiles_semaphore_->Signal();
534 return false; 523 return false;
535 } 524 }
536 } 525 }
537 current_profiles_.Add(new CpuProfile(title, uid, record_samples)); 526 current_profiles_.Add(new CpuProfile(title, uid, record_samples));
538 current_profiles_semaphore_->Signal(); 527 current_profiles_semaphore_->Signal();
539 return true; 528 return true;
540 } 529 }
541 530
542 531
543 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { 532 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title,
533 double actual_sampling_rate) {
544 const int title_len = StrLength(title); 534 const int title_len = StrLength(title);
545 CpuProfile* profile = NULL; 535 CpuProfile* profile = NULL;
546 current_profiles_semaphore_->Wait(); 536 current_profiles_semaphore_->Wait();
547 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 537 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
548 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) { 538 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) {
549 profile = current_profiles_.Remove(i); 539 profile = current_profiles_.Remove(i);
550 break; 540 break;
551 } 541 }
552 } 542 }
553 current_profiles_semaphore_->Signal(); 543 current_profiles_semaphore_->Signal();
554 544
555 if (profile == NULL) return NULL; 545 if (profile == NULL) return NULL;
556 profile->CalculateTotalTicksAndSamplingRate(); 546 profile->CalculateTotalTicks();
547 profile->SetActualSamplingRate(actual_sampling_rate);
557 finished_profiles_.Add(profile); 548 finished_profiles_.Add(profile);
558 return profile; 549 return profile;
559 } 550 }
560 551
561 552
562 bool CpuProfilesCollection::IsLastProfile(const char* title) { 553 bool CpuProfilesCollection::IsLastProfile(const char* title) {
563 // Called from VM thread, and only it can mutate the list, 554 // Called from VM thread, and only it can mutate the list,
564 // so no locking is needed here. 555 // so no locking is needed here.
565 if (current_profiles_.length() != 1) return false; 556 if (current_profiles_.length() != 1) return false;
566 return StrLength(title) == 0 557 return StrLength(title) == 0
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 CodeEntry* code_entry = new CodeEntry(tag, 594 CodeEntry* code_entry = new CodeEntry(tag,
604 name, 595 name,
605 name_prefix, 596 name_prefix,
606 resource_name, 597 resource_name,
607 line_number); 598 line_number);
608 code_entries_.Add(code_entry); 599 code_entries_.Add(code_entry);
609 return code_entry; 600 return code_entry;
610 } 601 }
611 602
612 603
604 void SampleRateCalculator::Tick() {
605 if (--wall_time_query_countdown_ == 0)
606 UpdateMeasurements(OS::TimeCurrentMillis());
607 }
608
609
610 void SampleRateCalculator::UpdateMeasurements(double current_time) {
611 if (measurements_count_++ != 0) {
612 const double measured_ticks_per_ms =
613 (kWallTimeQueryIntervalMs * ticks_per_ms_) /
614 (current_time - last_wall_time_);
615 // Update the average value.
616 ticks_per_ms_ +=
617 (measured_ticks_per_ms - ticks_per_ms_) / measurements_count_;
618 // Update the externally accessible result.
619 result_ = static_cast<AtomicWord>(ticks_per_ms_ * kResultScale);
620 }
621 last_wall_time_ = current_time;
622 wall_time_query_countdown_ =
623 static_cast<unsigned>(kWallTimeQueryIntervalMs * ticks_per_ms_);
624 }
625
626
613 const char* const ProfileGenerator::kAnonymousFunctionName = 627 const char* const ProfileGenerator::kAnonymousFunctionName =
614 "(anonymous function)"; 628 "(anonymous function)";
615 const char* const ProfileGenerator::kProgramEntryName = 629 const char* const ProfileGenerator::kProgramEntryName =
616 "(program)"; 630 "(program)";
617 const char* const ProfileGenerator::kGarbageCollectorEntryName = 631 const char* const ProfileGenerator::kGarbageCollectorEntryName =
618 "(garbage collector)"; 632 "(garbage collector)";
619 const char* const ProfileGenerator::kUnresolvedFunctionName = 633 const char* const ProfileGenerator::kUnresolvedFunctionName =
620 "(unresolved function)"; 634 "(unresolved function)";
621 635
622 636
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 if (no_symbolized_entries) { 717 if (no_symbolized_entries) {
704 *entry++ = EntryForVMState(sample.state); 718 *entry++ = EntryForVMState(sample.state);
705 } 719 }
706 } 720 }
707 721
708 profiles_->AddPathToCurrentProfiles(entries); 722 profiles_->AddPathToCurrentProfiles(entries);
709 } 723 }
710 724
711 725
712 } } // namespace v8::internal 726 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698