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

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

Issue 10444137: Expose last seen heap object id via v8 public api. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: test was added Created 8 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
« no previous file with comments | « src/profile-generator.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests for heap profiler 3 // Tests for heap profiler
4 4
5 #include <ctype.h> 5 #include <ctype.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "hashmap.h" 10 #include "hashmap.h"
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 int eos_signaled_; 684 int eos_signaled_;
685 int updates_written_; 685 int updates_written_;
686 uint32_t entries_count_; 686 uint32_t entries_count_;
687 uint32_t entries_size_; 687 uint32_t entries_size_;
688 int intervals_count_; 688 int intervals_count_;
689 int first_interval_index_; 689 int first_interval_index_;
690 }; 690 };
691 691
692 } // namespace 692 } // namespace
693 693
694 static TestStatsStream GetHeapStatsUpdate() { 694 static TestStatsStream GetHeapStatsUpdate(
695 v8::SnapshotObjectId* object_id = NULL) {
695 TestStatsStream stream; 696 TestStatsStream stream;
696 v8::HeapProfiler::PushHeapObjectsStats(&stream); 697 v8::SnapshotObjectId last_seen_id =
698 v8::HeapProfiler::PushHeapObjectsStats(&stream);
699 if (object_id)
700 *object_id = last_seen_id;
697 CHECK_EQ(1, stream.eos_signaled()); 701 CHECK_EQ(1, stream.eos_signaled());
698 return stream; 702 return stream;
699 } 703 }
700 704
701 705
702 TEST(HeapSnapshotObjectsStats) { 706 TEST(HeapSnapshotObjectsStats) {
703 v8::HandleScope scope; 707 v8::HandleScope scope;
704 LocalContext env; 708 LocalContext env;
705 709
706 v8::HeapProfiler::StartHeapObjectsTracking(); 710 v8::HeapProfiler::StartHeapObjectsTracking();
707 // We have to call GC 5 times. In other case the garbage will be 711 // We have to call GC 5 times. In other case the garbage will be
708 // the reason of flakiness. 712 // the reason of flakiness.
709 for (int i = 0; i < 5; ++i) { 713 for (int i = 0; i < 5; ++i) {
710 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 714 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
711 } 715 }
712 716
717 v8::SnapshotObjectId initial_id;
713 { 718 {
714 // Single chunk of data expected in update. Initial data. 719 // Single chunk of data expected in update. Initial data.
715 TestStatsStream stats_update = GetHeapStatsUpdate(); 720 TestStatsStream stats_update = GetHeapStatsUpdate(&initial_id);
716 CHECK_EQ(1, stats_update.intervals_count()); 721 CHECK_EQ(1, stats_update.intervals_count());
717 CHECK_EQ(1, stats_update.updates_written()); 722 CHECK_EQ(1, stats_update.updates_written());
718 CHECK_LT(0, stats_update.entries_size()); 723 CHECK_LT(0, stats_update.entries_size());
719 CHECK_EQ(0, stats_update.first_interval_index()); 724 CHECK_EQ(0, stats_update.first_interval_index());
720 } 725 }
721 726
722 // No data expected in update because nothing has happened. 727 // No data expected in update because nothing has happened.
723 CHECK_EQ(0, GetHeapStatsUpdate().updates_written()); 728 v8::SnapshotObjectId same_id;
729 CHECK_EQ(0, GetHeapStatsUpdate(&same_id).updates_written());
730 CHECK_EQ_SNAPSHOT_OBJECT_ID(initial_id, same_id);
731
724 { 732 {
733 v8::SnapshotObjectId additional_string_id;
725 v8::HandleScope inner_scope_1; 734 v8::HandleScope inner_scope_1;
726 v8_str("string1"); 735 v8_str("string1");
727 { 736 {
728 // Single chunk of data with one new entry expected in update. 737 // Single chunk of data with one new entry expected in update.
729 TestStatsStream stats_update = GetHeapStatsUpdate(); 738 TestStatsStream stats_update = GetHeapStatsUpdate(&additional_string_id);
739 CHECK_LT(same_id, additional_string_id);
730 CHECK_EQ(1, stats_update.intervals_count()); 740 CHECK_EQ(1, stats_update.intervals_count());
731 CHECK_EQ(1, stats_update.updates_written()); 741 CHECK_EQ(1, stats_update.updates_written());
732 CHECK_LT(0, stats_update.entries_size()); 742 CHECK_LT(0, stats_update.entries_size());
733 CHECK_EQ(1, stats_update.entries_count()); 743 CHECK_EQ(1, stats_update.entries_count());
734 CHECK_EQ(2, stats_update.first_interval_index()); 744 CHECK_EQ(2, stats_update.first_interval_index());
735 } 745 }
736 746
737 // No data expected in update because nothing happened. 747 // No data expected in update because nothing happened.
738 CHECK_EQ(0, GetHeapStatsUpdate().updates_written()); 748 v8::SnapshotObjectId last_id;
749 CHECK_EQ(0, GetHeapStatsUpdate(&last_id).updates_written());
750 CHECK_EQ_SNAPSHOT_OBJECT_ID(additional_string_id, last_id);
739 751
740 { 752 {
741 v8::HandleScope inner_scope_2; 753 v8::HandleScope inner_scope_2;
742 v8_str("string2"); 754 v8_str("string2");
743 755
744 uint32_t entries_size; 756 uint32_t entries_size;
745 { 757 {
746 v8::HandleScope inner_scope_3; 758 v8::HandleScope inner_scope_3;
747 v8_str("string3"); 759 v8_str("string3");
748 v8_str("string4"); 760 v8_str("string4");
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 const v8::HeapGraphNode* global_object = 1613 const v8::HeapGraphNode* global_object =
1602 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); 1614 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object");
1603 CHECK_NE(NULL, global_object); 1615 CHECK_NE(NULL, global_object);
1604 const v8::HeapGraphNode* properties = 1616 const v8::HeapGraphNode* properties =
1605 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); 1617 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties");
1606 CHECK_EQ(NULL, properties); 1618 CHECK_EQ(NULL, properties);
1607 const v8::HeapGraphNode* elements = 1619 const v8::HeapGraphNode* elements =
1608 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); 1620 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
1609 CHECK_EQ(NULL, elements); 1621 CHECK_EQ(NULL, elements);
1610 } 1622 }
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698