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 but aggregate byte counts. The byte counts will be | 349 // Saturate everything but aggregate byte counts. |
| 350 // pushed past the 32 bit value range. | 350 // In the 32 bit implementation, this tests the case where the low-order |
|
gab
2017/05/12 15:07:52
in the "64 bit implementation"?
Sigurður Ásgeirsson
2017/05/12 15:11:21
No, I specifically mean the 32 bit implementation,
gab
2017/05/12 15:13:41
Ah, indeed, right :)
| |
| 351 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); | 351 // word goes negative. |
| 352 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); | 352 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); |
| 353 EXPECT_EQ(data->alloc_ops(), INT_MAX); | 353 EXPECT_EQ(data->alloc_ops(), INT_MAX); |
| 354 EXPECT_EQ(data->free_ops(), INT_MAX); | 354 EXPECT_EQ(data->free_ops(), INT_MAX); |
| 355 // The cumulative byte counts are 64 bit wide, and won't saturate easily. | |
| 356 EXPECT_EQ(data->allocated_bytes(), | |
| 357 static_cast<int64_t>(INT_MAX) + | |
| 358 static_cast<int64_t>(3 * kAllocatedBytes)); | |
| 359 EXPECT_EQ(data->freed_bytes(), | |
| 360 static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes); | |
| 361 EXPECT_EQ(data->alloc_overhead_bytes(), | |
| 362 static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); | |
| 363 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); | |
| 364 | |
| 365 // The byte counts will be pushed past the 32 bit value range. | |
| 366 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); | |
| 367 EXPECT_EQ(data->alloc_ops(), INT_MAX); | |
| 368 EXPECT_EQ(data->free_ops(), INT_MAX); | |
| 355 // The cumulative byte counts are 64 bit wide, and won't saturate easily. | 369 // The cumulative byte counts are 64 bit wide, and won't saturate easily. |
| 356 EXPECT_EQ(data->allocated_bytes(), | 370 EXPECT_EQ(data->allocated_bytes(), |
| 357 2 * static_cast<int64_t>(INT_MAX) + | 371 2 * static_cast<int64_t>(INT_MAX) + |
| 358 static_cast<int64_t>(3 * kAllocatedBytes)); | 372 static_cast<int64_t>(3 * kAllocatedBytes)); |
| 359 EXPECT_EQ(data->freed_bytes(), | 373 EXPECT_EQ(data->freed_bytes(), |
| 360 2 * static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes); | 374 2 * static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes); |
| 361 EXPECT_EQ(data->alloc_overhead_bytes(), | 375 EXPECT_EQ(data->alloc_overhead_bytes(), |
| 362 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); | 376 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); |
| 363 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); | 377 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); |
| 364 } | 378 } |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1373 EXPECT_TRUE(thread.Start()); | 1387 EXPECT_TRUE(thread.Start()); |
| 1374 } | 1388 } |
| 1375 } | 1389 } |
| 1376 | 1390 |
| 1377 // Expect one ThreadData instance for each element in |kThreadNames| and one | 1391 // Expect one ThreadData instance for each element in |kThreadNames| and one |
| 1378 // ThreadData instance for the main thread. | 1392 // ThreadData instance for the main thread. |
| 1379 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); | 1393 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); |
| 1380 } | 1394 } |
| 1381 | 1395 |
| 1382 } // namespace tracked_objects | 1396 } // namespace tracked_objects |
| OLD | NEW |