| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/heap_profiler_heap_dump_writer.h" | 5 #include "base/trace_event/heap_profiler_heap_dump_writer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 std::string size; | 172 std::string size; |
| 173 ASSERT_TRUE(json_entry->GetString("size", &size)); | 173 ASSERT_TRUE(json_entry->GetString("size", &size)); |
| 174 ASSERT_EQ(large_value_str, size); | 174 ASSERT_EQ(large_value_str, size); |
| 175 | 175 |
| 176 std::string count; | 176 std::string count; |
| 177 ASSERT_TRUE(json_entry->GetString("count", &count)); | 177 ASSERT_TRUE(json_entry->GetString("count", &count)); |
| 178 ASSERT_EQ(large_value_str, count); | 178 ASSERT_EQ(large_value_str, count); |
| 179 } | 179 } |
| 180 | 180 |
| 181 TEST(HeapDumpWriterTest, BacktraceTypeNameTable) { | 181 TEST(HeapDumpWriterTest, BacktraceTypeNameTable) { |
| 182 hash_map<AllocationContext, AllocationMetrics> metrics_by_context; | 182 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context; |
| 183 | 183 |
| 184 AllocationContext ctx; | 184 AllocationContext ctx; |
| 185 ctx.backtrace.frames[0] = kBrowserMain; | 185 ctx.backtrace.frames[0] = kBrowserMain; |
| 186 ctx.backtrace.frames[1] = kCreateWidget; | 186 ctx.backtrace.frames[1] = kCreateWidget; |
| 187 ctx.backtrace.frame_count = 2; | 187 ctx.backtrace.frame_count = 2; |
| 188 ctx.type_name = kInt; | 188 ctx.type_name = kInt; |
| 189 | 189 |
| 190 // 10 bytes with context { type: int, bt: [BrowserMain, CreateWidget] }. | 190 // 10 bytes with context { type: int, bt: [BrowserMain, CreateWidget] }. |
| 191 metrics_by_context[ctx] = {10, 5}; | 191 metrics_by_context[ctx] = {10, 5}; |
| 192 | 192 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 AssertSizeAndCountEq(dump, bt_browser_main_create_widget, type_id_bool, | 267 AssertSizeAndCountEq(dump, bt_browser_main_create_widget, type_id_bool, |
| 268 {18, 18}); | 268 {18, 18}); |
| 269 | 269 |
| 270 // The type breakdown of the entrie heap should have been dumped as well. | 270 // The type breakdown of the entrie heap should have been dumped as well. |
| 271 AssertSizeAndCountEq(dump, -1, type_id_int, {10, 5}); | 271 AssertSizeAndCountEq(dump, -1, type_id_int, {10, 5}); |
| 272 AssertSizeAndCountEq(dump, -1, type_id_bool, {48, 48}); | 272 AssertSizeAndCountEq(dump, -1, type_id_bool, {48, 48}); |
| 273 AssertSizeAndCountEq(dump, -1, type_id_string, {19, 4}); | 273 AssertSizeAndCountEq(dump, -1, type_id_string, {19, 4}); |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST(HeapDumpWriterTest, InsignificantValuesNotDumped) { | 276 TEST(HeapDumpWriterTest, InsignificantValuesNotDumped) { |
| 277 hash_map<AllocationContext, AllocationMetrics> metrics_by_context; | 277 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context; |
| 278 | 278 |
| 279 AllocationContext ctx; | 279 AllocationContext ctx; |
| 280 ctx.backtrace.frames[0] = kBrowserMain; | 280 ctx.backtrace.frames[0] = kBrowserMain; |
| 281 ctx.backtrace.frames[1] = kCreateWidget; | 281 ctx.backtrace.frames[1] = kCreateWidget; |
| 282 ctx.backtrace.frame_count = 2; | 282 ctx.backtrace.frame_count = 2; |
| 283 | 283 |
| 284 // 0.5 KiB and 1 chunk in BrowserMain -> CreateWidget itself. | 284 // 0.5 KiB and 1 chunk in BrowserMain -> CreateWidget itself. |
| 285 metrics_by_context[ctx] = {512, 1}; | 285 metrics_by_context[ctx] = {512, 1}; |
| 286 | 286 |
| 287 // 1 MiB and 1 chunk in BrowserMain -> CreateWidget -> GetBitmap. | 287 // 1 MiB and 1 chunk in BrowserMain -> CreateWidget -> GetBitmap. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 {1024 * 1024 + 400 + 512, 3}); | 324 {1024 * 1024 + 400 + 512, 3}); |
| 325 AssertSizeAndCountEq(dump, bt_browser_main, -1, {1024 * 1024 + 400 + 512, 3}); | 325 AssertSizeAndCountEq(dump, bt_browser_main, -1, {1024 * 1024 + 400 + 512, 3}); |
| 326 | 326 |
| 327 // Initialize was not significant, it should not have been dumped. | 327 // Initialize was not significant, it should not have been dumped. |
| 328 AssertNotDumped(dump, bt_initialize, -1); | 328 AssertNotDumped(dump, bt_initialize, -1); |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace internal | 331 } // namespace internal |
| 332 } // namespace trace_event | 332 } // namespace trace_event |
| 333 } // namespace base | 333 } // namespace base |
| OLD | NEW |