Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Test of classes in the tracked_objects.h classes. | 5 // Test of classes in the tracked_objects.h classes. |
| 6 | 6 |
| 7 #include "base/tracked_objects.h" | 7 #include "base/tracked_objects.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 const int32_t kLargerMaxAllocatedBytes = kMaxAllocatedBytes * 2; | 339 const int32_t kLargerMaxAllocatedBytes = kMaxAllocatedBytes * 2; |
| 340 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, | 340 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, |
| 341 kAllocOverheadBytes, kLargerMaxAllocatedBytes); | 341 kAllocOverheadBytes, kLargerMaxAllocatedBytes); |
| 342 EXPECT_EQ(data->alloc_ops(), 3 * kAllocOps); | 342 EXPECT_EQ(data->alloc_ops(), 3 * kAllocOps); |
| 343 EXPECT_EQ(data->free_ops(), 3 * kFreeOps); | 343 EXPECT_EQ(data->free_ops(), 3 * kFreeOps); |
| 344 EXPECT_EQ(data->allocated_bytes(), 3 * kAllocatedBytes); | 344 EXPECT_EQ(data->allocated_bytes(), 3 * kAllocatedBytes); |
| 345 EXPECT_EQ(data->freed_bytes(), 3 * kFreedBytes); | 345 EXPECT_EQ(data->freed_bytes(), 3 * kFreedBytes); |
| 346 EXPECT_EQ(data->alloc_overhead_bytes(), 3 * kAllocOverheadBytes); | 346 EXPECT_EQ(data->alloc_overhead_bytes(), 3 * kAllocOverheadBytes); |
| 347 EXPECT_EQ(data->max_allocated_bytes(), kLargerMaxAllocatedBytes); | 347 EXPECT_EQ(data->max_allocated_bytes(), kLargerMaxAllocatedBytes); |
| 348 | 348 |
| 349 // Saturate everything. | 349 // Saturate the counts. |
| 350 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); | 350 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); |
|
gab
2017/05/02 21:17:12
INT_MAX no longer saturates though right?
Sigurður Ásgeirsson
2017/05/03 14:10:10
Comment amended to moar specific specificity.
| |
| 351 EXPECT_EQ(data->alloc_ops(), INT_MAX); | 351 EXPECT_EQ(data->alloc_ops(), INT_MAX); |
| 352 EXPECT_EQ(data->free_ops(), INT_MAX); | 352 EXPECT_EQ(data->free_ops(), INT_MAX); |
| 353 EXPECT_EQ(data->allocated_bytes(), INT_MAX); | 353 // The cumulative byte counts are 64 bit wide, and won't saturate easily. |
| 354 EXPECT_EQ(data->freed_bytes(), INT_MAX); | 354 EXPECT_EQ(data->allocated_bytes(), |
| 355 EXPECT_EQ(data->alloc_overhead_bytes(), INT_MAX); | 355 static_cast<int64_t>(INT_MAX) + |
| 356 static_cast<int64_t>(3 * kAllocatedBytes)); | |
| 357 EXPECT_EQ(data->freed_bytes(), | |
| 358 static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes); | |
| 359 EXPECT_EQ(data->alloc_overhead_bytes(), | |
| 360 static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); | |
| 356 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); | 361 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); |
| 357 } | 362 } |
|
gab
2017/05/02 21:17:12
Do we have any tests that verify the new range bey
Sigurður Ásgeirsson
2017/05/03 14:10:10
The test above now goes to 2^32 + some.
| |
| 358 | 363 |
| 359 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { | 364 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { |
| 360 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 365 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
| 361 | 366 |
| 362 std::unique_ptr<DeathData> data(new DeathData()); | 367 std::unique_ptr<DeathData> data(new DeathData()); |
| 363 ASSERT_NE(data, nullptr); | 368 ASSERT_NE(data, nullptr); |
| 364 | 369 |
| 365 const int32_t run_ms = 42; | 370 const int32_t run_ms = 42; |
| 366 const int32_t queue_ms = 8; | 371 const int32_t queue_ms = 8; |
| 367 | 372 |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1366 EXPECT_TRUE(thread.Start()); | 1371 EXPECT_TRUE(thread.Start()); |
| 1367 } | 1372 } |
| 1368 } | 1373 } |
| 1369 | 1374 |
| 1370 // Expect one ThreadData instance for each element in |kThreadNames| and one | 1375 // Expect one ThreadData instance for each element in |kThreadNames| and one |
| 1371 // ThreadData instance for the main thread. | 1376 // ThreadData instance for the main thread. |
| 1372 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); | 1377 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); |
| 1373 } | 1378 } |
| 1374 | 1379 |
| 1375 } // namespace tracked_objects | 1380 } // namespace tracked_objects |
| OLD | NEW |