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

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

Issue 983833006: Remove uid and title from HeapSnapshot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@cpu-profiling
Patch Set: Created 5 years, 9 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
« include/v8-profiler.h ('K') | « src/heap-snapshot-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 // 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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 heap_profiler->DeleteAllHeapSnapshots(); 1609 heap_profiler->DeleteAllHeapSnapshots();
1610 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1610 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1611 CHECK(heap_profiler->TakeHeapSnapshot(v8_str("1"))); 1611 CHECK(heap_profiler->TakeHeapSnapshot(v8_str("1")));
1612 CHECK(heap_profiler->TakeHeapSnapshot(v8_str("2"))); 1612 CHECK(heap_profiler->TakeHeapSnapshot(v8_str("2")));
1613 CHECK_EQ(2, heap_profiler->GetSnapshotCount()); 1613 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1614 heap_profiler->DeleteAllHeapSnapshots(); 1614 heap_profiler->DeleteAllHeapSnapshots();
1615 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1615 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1616 } 1616 }
1617 1617
1618 1618
1619 static const v8::HeapSnapshot* FindHeapSnapshot(v8::HeapProfiler* profiler, 1619 static bool FindHeapSnapshot(v8::HeapProfiler* profiler,
1620 unsigned uid) { 1620 const v8::HeapSnapshot* snapshot) {
1621 int length = profiler->GetSnapshotCount(); 1621 int length = profiler->GetSnapshotCount();
1622 for (int i = 0; i < length; i++) { 1622 for (int i = 0; i < length; i++) {
1623 const v8::HeapSnapshot* snapshot = profiler->GetHeapSnapshot(i); 1623 if (snapshot == profiler->GetHeapSnapshot(i)) return true;
1624 if (snapshot->GetUid() == uid) {
1625 return snapshot;
1626 }
1627 } 1624 }
1628 return NULL; 1625 return false;
1629 } 1626 }
1630 1627
1631 1628
1632 TEST(DeleteHeapSnapshot) { 1629 TEST(DeleteHeapSnapshot) {
1633 LocalContext env; 1630 LocalContext env;
1634 v8::HandleScope scope(env->GetIsolate()); 1631 v8::HandleScope scope(env->GetIsolate());
1635 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1632 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1636 1633
1637 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1634 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1638 const v8::HeapSnapshot* s1 = 1635 const v8::HeapSnapshot* s1 =
1639 heap_profiler->TakeHeapSnapshot(v8_str("1")); 1636 heap_profiler->TakeHeapSnapshot(v8_str("1"));
1640 1637
1641 CHECK(s1); 1638 CHECK(s1);
1642 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1639 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1643 unsigned uid1 = s1->GetUid(); 1640 CHECK(FindHeapSnapshot(heap_profiler, s1));
1644 CHECK_EQ(s1, FindHeapSnapshot(heap_profiler, uid1));
1645 const_cast<v8::HeapSnapshot*>(s1)->Delete(); 1641 const_cast<v8::HeapSnapshot*>(s1)->Delete();
1646 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1642 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1647 CHECK(!FindHeapSnapshot(heap_profiler, uid1)); 1643 CHECK(!FindHeapSnapshot(heap_profiler, s1));
1648 1644
1649 const v8::HeapSnapshot* s2 = 1645 const v8::HeapSnapshot* s2 =
1650 heap_profiler->TakeHeapSnapshot(v8_str("2")); 1646 heap_profiler->TakeHeapSnapshot(v8_str("2"));
1651 CHECK(s2); 1647 CHECK(s2);
1652 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1648 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1653 unsigned uid2 = s2->GetUid(); 1649 CHECK(FindHeapSnapshot(heap_profiler, s2));
1654 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
1655 CHECK_EQ(s2, FindHeapSnapshot(heap_profiler, uid2));
1656 const v8::HeapSnapshot* s3 = 1650 const v8::HeapSnapshot* s3 =
1657 heap_profiler->TakeHeapSnapshot(v8_str("3")); 1651 heap_profiler->TakeHeapSnapshot(v8_str("3"));
1658 CHECK(s3); 1652 CHECK(s3);
1659 CHECK_EQ(2, heap_profiler->GetSnapshotCount()); 1653 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1660 unsigned uid3 = s3->GetUid(); 1654 CHECK_NE(s2, s3);
1661 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 1655 CHECK(FindHeapSnapshot(heap_profiler, s3));
1662 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
1663 const_cast<v8::HeapSnapshot*>(s2)->Delete(); 1656 const_cast<v8::HeapSnapshot*>(s2)->Delete();
1664 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1657 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1665 CHECK(!FindHeapSnapshot(heap_profiler, uid2)); 1658 CHECK(!FindHeapSnapshot(heap_profiler, s2));
1666 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3)); 1659 CHECK(FindHeapSnapshot(heap_profiler, s3));
1667 const_cast<v8::HeapSnapshot*>(s3)->Delete(); 1660 const_cast<v8::HeapSnapshot*>(s3)->Delete();
1668 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1661 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1669 CHECK(!FindHeapSnapshot(heap_profiler, uid3)); 1662 CHECK(!FindHeapSnapshot(heap_profiler, s3));
1670 } 1663 }
1671 1664
1672 1665
1673 class NameResolver : public v8::HeapProfiler::ObjectNameResolver { 1666 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1674 public: 1667 public:
1675 virtual const char* GetName(v8::Handle<v8::Object> object) { 1668 virtual const char* GetName(v8::Handle<v8::Object> object) {
1676 return "Global object name"; 1669 return "Global object name";
1677 } 1670 }
1678 }; 1671 };
1679 1672
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 map.AddRange(ToAddress(0x180), 0x80, 6U); 2822 map.AddRange(ToAddress(0x180), 0x80, 6U);
2830 map.AddRange(ToAddress(0x180), 0x80, 7U); 2823 map.AddRange(ToAddress(0x180), 0x80, 7U);
2831 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2824 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2832 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2825 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2833 CHECK_EQ(3u, map.size()); 2826 CHECK_EQ(3u, map.size());
2834 2827
2835 map.Clear(); 2828 map.Clear();
2836 CHECK_EQ(0u, map.size()); 2829 CHECK_EQ(0u, map.size());
2837 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2830 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2838 } 2831 }
OLDNEW
« include/v8-profiler.h ('K') | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698