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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 else | 73 else |
74 EXPECT_NE(reinterpret_cast<Births*>(NULL), birth); | 74 EXPECT_NE(reinterpret_cast<Births*>(NULL), birth); |
75 } | 75 } |
76 | 76 |
77 // Helper function to verify the most common test expectations. | 77 // Helper function to verify the most common test expectations. |
78 void ExpectSimpleProcessData(const ProcessDataSnapshot& process_data, | 78 void ExpectSimpleProcessData(const ProcessDataSnapshot& process_data, |
79 const std::string& function_name, | 79 const std::string& function_name, |
80 const std::string& birth_thread, | 80 const std::string& birth_thread, |
81 const std::string& death_thread, | 81 const std::string& death_thread, |
82 int count, | 82 int count, |
83 int run_ms, | 83 int run_duration, |
84 int queue_ms) { | 84 int queue_duration) { |
85 ASSERT_EQ(1u, process_data.phased_snapshots.size()); | 85 ASSERT_EQ(1u, process_data.phased_snapshots.size()); |
86 auto it = process_data.phased_snapshots.find(0); | 86 auto it = process_data.phased_snapshots.find(0); |
87 ASSERT_TRUE(it != process_data.phased_snapshots.end()); | 87 ASSERT_TRUE(it != process_data.phased_snapshots.end()); |
88 const ProcessDataPhaseSnapshot& process_data_phase = it->second; | 88 const ProcessDataPhaseSnapshot& process_data_phase = it->second; |
89 | 89 |
90 ASSERT_EQ(1u, process_data_phase.tasks.size()); | 90 ASSERT_EQ(1u, process_data_phase.tasks.size()); |
91 | 91 |
92 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name); | 92 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name); |
93 EXPECT_EQ(function_name, | 93 EXPECT_EQ(function_name, |
94 process_data_phase.tasks[0].birth.location.function_name); | 94 process_data_phase.tasks[0].birth.location.function_name); |
95 EXPECT_EQ(kLineNumber, | 95 EXPECT_EQ(kLineNumber, |
96 process_data_phase.tasks[0].birth.location.line_number); | 96 process_data_phase.tasks[0].birth.location.line_number); |
97 | 97 |
98 EXPECT_EQ(birth_thread, | 98 EXPECT_EQ(birth_thread, |
99 process_data_phase.tasks[0].birth.sanitized_thread_name); | 99 process_data_phase.tasks[0].birth.sanitized_thread_name); |
100 | 100 |
101 EXPECT_EQ(count, process_data_phase.tasks[0].death_data.count); | 101 EXPECT_EQ(count, process_data_phase.tasks[0].death_data.count); |
102 EXPECT_EQ(count * run_ms, | 102 EXPECT_EQ(count * run_duration, |
103 process_data_phase.tasks[0].death_data.run_duration_sum); | 103 process_data_phase.tasks[0].death_data.run_duration_sum); |
104 EXPECT_EQ(run_ms, process_data_phase.tasks[0].death_data.run_duration_max); | 104 EXPECT_EQ(run_duration, |
105 EXPECT_EQ(run_ms, | 105 process_data_phase.tasks[0].death_data.run_duration_max); |
| 106 EXPECT_EQ(run_duration, |
106 process_data_phase.tasks[0].death_data.run_duration_sample); | 107 process_data_phase.tasks[0].death_data.run_duration_sample); |
107 EXPECT_EQ(count * queue_ms, | 108 EXPECT_EQ(count * queue_duration, |
108 process_data_phase.tasks[0].death_data.queue_duration_sum); | 109 process_data_phase.tasks[0].death_data.queue_duration_sum); |
109 EXPECT_EQ(queue_ms, | 110 EXPECT_EQ(queue_duration, |
110 process_data_phase.tasks[0].death_data.queue_duration_max); | 111 process_data_phase.tasks[0].death_data.queue_duration_max); |
111 EXPECT_EQ(queue_ms, | 112 EXPECT_EQ(queue_duration, |
112 process_data_phase.tasks[0].death_data.queue_duration_sample); | 113 process_data_phase.tasks[0].death_data.queue_duration_sample); |
113 | 114 |
114 EXPECT_EQ(death_thread, | 115 EXPECT_EQ(death_thread, |
115 process_data_phase.tasks[0].death_sanitized_thread_name); | 116 process_data_phase.tasks[0].death_sanitized_thread_name); |
116 | 117 |
117 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); | 118 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); |
118 } | 119 } |
119 | 120 |
120 // Sets time that will be returned by ThreadData::Now(). | 121 // Sets time that will be returned by ThreadData::Now(). |
121 static void SetTestTime(unsigned int test_time) { test_time_ = test_time; } | 122 static void SetTestTime(unsigned int test_time) { test_time_ = test_time; } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ASSERT_NE(data, nullptr); | 269 ASSERT_NE(data, nullptr); |
269 EXPECT_EQ(data->run_duration_sum(), 0); | 270 EXPECT_EQ(data->run_duration_sum(), 0); |
270 EXPECT_EQ(data->run_duration_max(), 0); | 271 EXPECT_EQ(data->run_duration_max(), 0); |
271 EXPECT_EQ(data->run_duration_sample(), 0); | 272 EXPECT_EQ(data->run_duration_sample(), 0); |
272 EXPECT_EQ(data->queue_duration_sum(), 0); | 273 EXPECT_EQ(data->queue_duration_sum(), 0); |
273 EXPECT_EQ(data->queue_duration_max(), 0); | 274 EXPECT_EQ(data->queue_duration_max(), 0); |
274 EXPECT_EQ(data->queue_duration_sample(), 0); | 275 EXPECT_EQ(data->queue_duration_sample(), 0); |
275 EXPECT_EQ(data->count(), 0); | 276 EXPECT_EQ(data->count(), 0); |
276 EXPECT_EQ(nullptr, data->last_phase_snapshot()); | 277 EXPECT_EQ(nullptr, data->last_phase_snapshot()); |
277 | 278 |
278 int32_t run_ms = 42; | 279 base::TimeDelta run_duration = base::TimeDelta::FromMilliseconds(42); |
279 int32_t queue_ms = 8; | 280 base::TimeDelta queue_duration = base::TimeDelta::FromMilliseconds(8); |
280 | 281 |
281 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. | 282 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. |
282 data->RecordDurations(queue_ms, run_ms, kUnrandomInt); | 283 data->RecordDurations(queue_duration, run_duration, kUnrandomInt); |
283 EXPECT_EQ(data->run_duration_sum(), run_ms); | 284 EXPECT_EQ(data->run_duration_sum(), run_duration.InMilliseconds()); |
284 EXPECT_EQ(data->run_duration_max(), run_ms); | 285 EXPECT_EQ(data->run_duration_max(), run_duration.InMilliseconds()); |
285 EXPECT_EQ(data->run_duration_sample(), run_ms); | 286 EXPECT_EQ(data->run_duration_sample(), run_duration.InMilliseconds()); |
286 EXPECT_EQ(data->queue_duration_sum(), queue_ms); | 287 EXPECT_EQ(data->queue_duration_sum(), queue_duration.InMilliseconds()); |
287 EXPECT_EQ(data->queue_duration_max(), queue_ms); | 288 EXPECT_EQ(data->queue_duration_max(), queue_duration.InMilliseconds()); |
288 EXPECT_EQ(data->queue_duration_sample(), queue_ms); | 289 EXPECT_EQ(data->queue_duration_sample(), queue_duration.InMilliseconds()); |
289 EXPECT_EQ(data->count(), 1); | 290 EXPECT_EQ(data->count(), 1); |
290 EXPECT_EQ(nullptr, data->last_phase_snapshot()); | 291 EXPECT_EQ(nullptr, data->last_phase_snapshot()); |
291 | 292 |
292 data->RecordDurations(queue_ms, run_ms, kUnrandomInt); | 293 data->RecordDurations(queue_duration, run_duration, kUnrandomInt); |
293 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms); | 294 EXPECT_EQ(data->run_duration_sum(), |
294 EXPECT_EQ(data->run_duration_max(), run_ms); | 295 (run_duration + run_duration).InMilliseconds()); |
295 EXPECT_EQ(data->run_duration_sample(), run_ms); | 296 EXPECT_EQ(data->run_duration_max(), run_duration.InMilliseconds()); |
296 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms); | 297 EXPECT_EQ(data->run_duration_sample(), run_duration.InMilliseconds()); |
297 EXPECT_EQ(data->queue_duration_max(), queue_ms); | 298 EXPECT_EQ(data->queue_duration_sum(), |
298 EXPECT_EQ(data->queue_duration_sample(), queue_ms); | 299 (queue_duration + queue_duration).InMilliseconds()); |
| 300 EXPECT_EQ(data->queue_duration_max(), queue_duration.InMilliseconds()); |
| 301 EXPECT_EQ(data->queue_duration_sample(), queue_duration.InMilliseconds()); |
299 EXPECT_EQ(data->count(), 2); | 302 EXPECT_EQ(data->count(), 2); |
300 EXPECT_EQ(nullptr, data->last_phase_snapshot()); | 303 EXPECT_EQ(nullptr, data->last_phase_snapshot()); |
301 } | 304 } |
302 | 305 |
303 TEST_F(TrackedObjectsTest, DeathDataTestRecordAllocations) { | 306 TEST_F(TrackedObjectsTest, DeathDataTestRecordAllocations) { |
304 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 307 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
305 | 308 |
306 std::unique_ptr<DeathData> data(new DeathData()); | 309 std::unique_ptr<DeathData> data(new DeathData()); |
307 ASSERT_NE(data, nullptr); | 310 ASSERT_NE(data, nullptr); |
308 | 311 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); | 379 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); |
377 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); | 380 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); |
378 } | 381 } |
379 | 382 |
380 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { | 383 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { |
381 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 384 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
382 | 385 |
383 std::unique_ptr<DeathData> data(new DeathData()); | 386 std::unique_ptr<DeathData> data(new DeathData()); |
384 ASSERT_NE(data, nullptr); | 387 ASSERT_NE(data, nullptr); |
385 | 388 |
386 const int32_t run_ms = 42; | 389 const base::TimeDelta run_duration = base::TimeDelta::FromMilliseconds(42); |
387 const int32_t queue_ms = 8; | 390 const base::TimeDelta queue_duration = base::TimeDelta::FromMilliseconds(8); |
388 | 391 |
389 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. | 392 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. |
390 data->RecordDurations(queue_ms, run_ms, kUnrandomInt); | 393 data->RecordDurations(queue_duration, run_duration, kUnrandomInt); |
391 data->RecordDurations(queue_ms, run_ms, kUnrandomInt); | 394 data->RecordDurations(queue_duration, run_duration, kUnrandomInt); |
392 | 395 |
393 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, | 396 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, |
394 kAllocOverheadBytes, kMaxAllocatedBytes); | 397 kAllocOverheadBytes, kMaxAllocatedBytes); |
395 | 398 |
396 data->OnProfilingPhaseCompleted(123); | 399 data->OnProfilingPhaseCompleted(123); |
397 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms); | 400 EXPECT_EQ(data->run_duration_sum(), |
| 401 (run_duration + run_duration).InMilliseconds()); |
398 EXPECT_EQ(data->run_duration_max(), 0); | 402 EXPECT_EQ(data->run_duration_max(), 0); |
399 EXPECT_EQ(data->run_duration_sample(), run_ms); | 403 EXPECT_EQ(data->run_duration_sample(), run_duration.InMilliseconds()); |
400 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms); | 404 EXPECT_EQ(data->queue_duration_sum(), |
| 405 (queue_duration + queue_duration).InMilliseconds()); |
401 EXPECT_EQ(data->queue_duration_max(), 0); | 406 EXPECT_EQ(data->queue_duration_max(), 0); |
402 EXPECT_EQ(data->queue_duration_sample(), queue_ms); | 407 EXPECT_EQ(data->queue_duration_sample(), queue_duration.InMilliseconds()); |
403 EXPECT_EQ(data->count(), 2); | 408 EXPECT_EQ(data->count(), 2); |
404 | 409 |
405 EXPECT_EQ(data->alloc_ops(), kAllocOps); | 410 EXPECT_EQ(data->alloc_ops(), kAllocOps); |
406 EXPECT_EQ(data->free_ops(), kFreeOps); | 411 EXPECT_EQ(data->free_ops(), kFreeOps); |
407 EXPECT_EQ(data->allocated_bytes(), kAllocatedBytes); | 412 EXPECT_EQ(data->allocated_bytes(), kAllocatedBytes); |
408 EXPECT_EQ(data->freed_bytes(), kFreedBytes); | 413 EXPECT_EQ(data->freed_bytes(), kFreedBytes); |
409 EXPECT_EQ(data->alloc_overhead_bytes(), kAllocOverheadBytes); | 414 EXPECT_EQ(data->alloc_overhead_bytes(), kAllocOverheadBytes); |
410 EXPECT_EQ(data->max_allocated_bytes(), kMaxAllocatedBytes); | 415 EXPECT_EQ(data->max_allocated_bytes(), kMaxAllocatedBytes); |
411 | 416 |
412 ASSERT_NE(nullptr, data->last_phase_snapshot()); | 417 ASSERT_NE(nullptr, data->last_phase_snapshot()); |
413 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase); | 418 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase); |
414 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count); | 419 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count); |
415 EXPECT_EQ(2 * run_ms, | 420 EXPECT_EQ(2 * run_duration.InMilliseconds(), |
416 data->last_phase_snapshot()->death_data.run_duration_sum); | 421 data->last_phase_snapshot()->death_data.run_duration_sum); |
417 EXPECT_EQ(run_ms, data->last_phase_snapshot()->death_data.run_duration_max); | 422 EXPECT_EQ(run_duration.InMilliseconds(), |
418 EXPECT_EQ(run_ms, | 423 data->last_phase_snapshot()->death_data.run_duration_max); |
| 424 EXPECT_EQ(run_duration.InMilliseconds(), |
419 data->last_phase_snapshot()->death_data.run_duration_sample); | 425 data->last_phase_snapshot()->death_data.run_duration_sample); |
420 EXPECT_EQ(2 * queue_ms, | 426 EXPECT_EQ(2 * queue_duration.InMilliseconds(), |
421 data->last_phase_snapshot()->death_data.queue_duration_sum); | 427 data->last_phase_snapshot()->death_data.queue_duration_sum); |
422 EXPECT_EQ(queue_ms, | 428 EXPECT_EQ(queue_duration.InMilliseconds(), |
423 data->last_phase_snapshot()->death_data.queue_duration_max); | 429 data->last_phase_snapshot()->death_data.queue_duration_max); |
424 EXPECT_EQ(queue_ms, | 430 EXPECT_EQ(queue_duration.InMilliseconds(), |
425 data->last_phase_snapshot()->death_data.queue_duration_sample); | 431 data->last_phase_snapshot()->death_data.queue_duration_sample); |
426 | 432 |
427 EXPECT_EQ(kAllocOps, data->last_phase_snapshot()->death_data.alloc_ops); | 433 EXPECT_EQ(kAllocOps, data->last_phase_snapshot()->death_data.alloc_ops); |
428 EXPECT_EQ(kFreeOps, data->last_phase_snapshot()->death_data.free_ops); | 434 EXPECT_EQ(kFreeOps, data->last_phase_snapshot()->death_data.free_ops); |
429 EXPECT_EQ(kAllocatedBytes, | 435 EXPECT_EQ(kAllocatedBytes, |
430 data->last_phase_snapshot()->death_data.allocated_bytes); | 436 data->last_phase_snapshot()->death_data.allocated_bytes); |
431 EXPECT_EQ(kFreedBytes, data->last_phase_snapshot()->death_data.freed_bytes); | 437 EXPECT_EQ(kFreedBytes, data->last_phase_snapshot()->death_data.freed_bytes); |
432 EXPECT_EQ(kAllocOverheadBytes, | 438 EXPECT_EQ(kAllocOverheadBytes, |
433 data->last_phase_snapshot()->death_data.alloc_overhead_bytes); | 439 data->last_phase_snapshot()->death_data.alloc_overhead_bytes); |
434 EXPECT_EQ(kMaxAllocatedBytes, | 440 EXPECT_EQ(kMaxAllocatedBytes, |
435 data->last_phase_snapshot()->death_data.max_allocated_bytes); | 441 data->last_phase_snapshot()->death_data.max_allocated_bytes); |
436 | 442 |
437 EXPECT_EQ(nullptr, data->last_phase_snapshot()->prev); | 443 EXPECT_EQ(nullptr, data->last_phase_snapshot()->prev); |
438 | 444 |
439 const int32_t run_ms1 = 21; | 445 const base::TimeDelta run_duration1 = base::TimeDelta::FromMilliseconds(21); |
440 const int32_t queue_ms1 = 4; | 446 const base::TimeDelta queue_duration1 = base::TimeDelta::FromMilliseconds(4); |
441 | 447 |
442 data->RecordDurations(queue_ms1, run_ms1, kUnrandomInt); | 448 data->RecordDurations(queue_duration1, run_duration1, kUnrandomInt); |
443 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, | 449 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, |
444 kAllocOverheadBytes, kMaxAllocatedBytes); | 450 kAllocOverheadBytes, kMaxAllocatedBytes); |
445 | 451 |
446 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms + run_ms1); | 452 EXPECT_EQ(data->run_duration_sum(), |
447 EXPECT_EQ(data->run_duration_max(), run_ms1); | 453 (run_duration + run_duration + run_duration1).InMilliseconds()); |
448 EXPECT_EQ(data->run_duration_sample(), run_ms1); | 454 EXPECT_EQ(data->run_duration_max(), run_duration1.InMilliseconds()); |
449 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms + queue_ms1); | 455 EXPECT_EQ(data->run_duration_sample(), run_duration1.InMilliseconds()); |
450 EXPECT_EQ(data->queue_duration_max(), queue_ms1); | 456 EXPECT_EQ( |
451 EXPECT_EQ(data->queue_duration_sample(), queue_ms1); | 457 data->queue_duration_sum(), |
| 458 (queue_duration + queue_duration + queue_duration1).InMilliseconds()); |
| 459 EXPECT_EQ(data->queue_duration_max(), queue_duration1.InMilliseconds()); |
| 460 EXPECT_EQ(data->queue_duration_sample(), queue_duration1.InMilliseconds()); |
452 EXPECT_EQ(data->count(), 3); | 461 EXPECT_EQ(data->count(), 3); |
453 | 462 |
454 EXPECT_EQ(data->alloc_ops(), 2 * kAllocOps); | 463 EXPECT_EQ(data->alloc_ops(), 2 * kAllocOps); |
455 EXPECT_EQ(data->free_ops(), 2 * kFreeOps); | 464 EXPECT_EQ(data->free_ops(), 2 * kFreeOps); |
456 EXPECT_EQ(data->allocated_bytes(), 2 * kAllocatedBytes); | 465 EXPECT_EQ(data->allocated_bytes(), 2 * kAllocatedBytes); |
457 EXPECT_EQ(data->freed_bytes(), 2 * kFreedBytes); | 466 EXPECT_EQ(data->freed_bytes(), 2 * kFreedBytes); |
458 EXPECT_EQ(data->alloc_overhead_bytes(), 2 * kAllocOverheadBytes); | 467 EXPECT_EQ(data->alloc_overhead_bytes(), 2 * kAllocOverheadBytes); |
459 EXPECT_EQ(data->max_allocated_bytes(), kMaxAllocatedBytes); | 468 EXPECT_EQ(data->max_allocated_bytes(), kMaxAllocatedBytes); |
460 | 469 |
461 ASSERT_NE(nullptr, data->last_phase_snapshot()); | 470 ASSERT_NE(nullptr, data->last_phase_snapshot()); |
462 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase); | 471 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase); |
463 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count); | 472 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count); |
464 EXPECT_EQ(2 * run_ms, | 473 EXPECT_EQ(2 * run_duration.InMilliseconds(), |
465 data->last_phase_snapshot()->death_data.run_duration_sum); | 474 data->last_phase_snapshot()->death_data.run_duration_sum); |
466 EXPECT_EQ(run_ms, data->last_phase_snapshot()->death_data.run_duration_max); | 475 EXPECT_EQ(run_duration.InMilliseconds(), |
467 EXPECT_EQ(run_ms, | 476 data->last_phase_snapshot()->death_data.run_duration_max); |
| 477 EXPECT_EQ(run_duration.InMilliseconds(), |
468 data->last_phase_snapshot()->death_data.run_duration_sample); | 478 data->last_phase_snapshot()->death_data.run_duration_sample); |
469 EXPECT_EQ(2 * queue_ms, | 479 EXPECT_EQ(2 * queue_duration.InMilliseconds(), |
470 data->last_phase_snapshot()->death_data.queue_duration_sum); | 480 data->last_phase_snapshot()->death_data.queue_duration_sum); |
471 EXPECT_EQ(queue_ms, | 481 EXPECT_EQ(queue_duration.InMilliseconds(), |
472 data->last_phase_snapshot()->death_data.queue_duration_max); | 482 data->last_phase_snapshot()->death_data.queue_duration_max); |
473 EXPECT_EQ(queue_ms, | 483 EXPECT_EQ(queue_duration.InMilliseconds(), |
474 data->last_phase_snapshot()->death_data.queue_duration_sample); | 484 data->last_phase_snapshot()->death_data.queue_duration_sample); |
475 | 485 |
476 EXPECT_EQ(kAllocOps, data->last_phase_snapshot()->death_data.alloc_ops); | 486 EXPECT_EQ(kAllocOps, data->last_phase_snapshot()->death_data.alloc_ops); |
477 EXPECT_EQ(kFreeOps, data->last_phase_snapshot()->death_data.free_ops); | 487 EXPECT_EQ(kFreeOps, data->last_phase_snapshot()->death_data.free_ops); |
478 EXPECT_EQ(kAllocatedBytes, | 488 EXPECT_EQ(kAllocatedBytes, |
479 data->last_phase_snapshot()->death_data.allocated_bytes); | 489 data->last_phase_snapshot()->death_data.allocated_bytes); |
480 EXPECT_EQ(kFreedBytes, data->last_phase_snapshot()->death_data.freed_bytes); | 490 EXPECT_EQ(kFreedBytes, data->last_phase_snapshot()->death_data.freed_bytes); |
481 EXPECT_EQ(kAllocOverheadBytes, | 491 EXPECT_EQ(kAllocOverheadBytes, |
482 data->last_phase_snapshot()->death_data.alloc_overhead_bytes); | 492 data->last_phase_snapshot()->death_data.alloc_overhead_bytes); |
483 EXPECT_EQ(kMaxAllocatedBytes, | 493 EXPECT_EQ(kMaxAllocatedBytes, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 1, 0, 0); | 618 1, 0, 0); |
609 } | 619 } |
610 | 620 |
611 TEST_F(TrackedObjectsTest, LifeCycleToSnapshotMainThread) { | 621 TEST_F(TrackedObjectsTest, LifeCycleToSnapshotMainThread) { |
612 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 622 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
613 | 623 |
614 const char kFunction[] = "LifeCycleToSnapshotMainThread"; | 624 const char kFunction[] = "LifeCycleToSnapshotMainThread"; |
615 Location location(kFunction, kFile, kLineNumber, NULL); | 625 Location location(kFunction, kFile, kLineNumber, NULL); |
616 TallyABirth(location, kMainThreadName); | 626 TallyABirth(location, kMainThreadName); |
617 | 627 |
618 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 628 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000); |
619 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 629 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
620 // TrackingInfo will call TallyABirth() during construction. | 630 // TrackingInfo will call TallyABirth() during construction. |
621 base::TrackingInfo pending_task(location, kDelayedStartTime); | 631 base::TrackingInfo pending_task(location, kDelayedStartTime); |
622 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 632 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
623 | 633 |
624 const unsigned int kStartOfRun = 5; | 634 const unsigned int kStartOfRun = 5; |
625 const unsigned int kEndOfRun = 7; | 635 const unsigned int kEndOfRun = 7; |
626 SetTestTime(kStartOfRun); | 636 SetTestTime(kStartOfRun); |
627 TaskStopwatch stopwatch; | 637 TaskStopwatch stopwatch; |
628 stopwatch.Start(); | 638 stopwatch.Start(); |
629 SetTestTime(kEndOfRun); | 639 SetTestTime(kEndOfRun); |
630 stopwatch.Stop(); | 640 stopwatch.Stop(); |
631 | 641 |
632 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); | 642 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); |
633 | 643 |
634 ProcessDataSnapshot process_data; | 644 ProcessDataSnapshot process_data; |
635 ThreadData::Snapshot(0, &process_data); | 645 ThreadData::Snapshot(0, &process_data); |
636 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, | 646 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, |
637 kMainThreadName, 1, 2, 4); | 647 kMainThreadName, 1, 2, 4); |
638 } | 648 } |
639 | 649 |
640 TEST_F(TrackedObjectsTest, TwoPhases) { | 650 TEST_F(TrackedObjectsTest, TwoPhases) { |
641 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 651 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
642 | 652 |
643 const char kFunction[] = "TwoPhases"; | 653 const char kFunction[] = "TwoPhases"; |
644 Location location(kFunction, kFile, kLineNumber, NULL); | 654 Location location(kFunction, kFile, kLineNumber, NULL); |
645 TallyABirth(location, kMainThreadName); | 655 TallyABirth(location, kMainThreadName); |
646 | 656 |
647 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 657 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000); |
648 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 658 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
649 // TrackingInfo will call TallyABirth() during construction. | 659 // TrackingInfo will call TallyABirth() during construction. |
650 base::TrackingInfo pending_task(location, kDelayedStartTime); | 660 base::TrackingInfo pending_task(location, kDelayedStartTime); |
651 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 661 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
652 | 662 |
653 const unsigned int kStartOfRun = 5; | 663 const unsigned int kStartOfRun = 5; |
654 const unsigned int kEndOfRun = 7; | 664 const unsigned int kEndOfRun = 7; |
655 SetTestTime(kStartOfRun); | 665 SetTestTime(kStartOfRun); |
656 TaskStopwatch stopwatch; | 666 TaskStopwatch stopwatch; |
657 stopwatch.Start(); | 667 stopwatch.Start(); |
658 SetTestTime(kEndOfRun); | 668 SetTestTime(kEndOfRun); |
659 stopwatch.Stop(); | 669 stopwatch.Stop(); |
660 | 670 |
661 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); | 671 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); |
662 | 672 |
663 ThreadData::OnProfilingPhaseCompleted(0); | 673 ThreadData::OnProfilingPhaseCompleted(0); |
664 | 674 |
665 TallyABirth(location, kMainThreadName); | 675 TallyABirth(location, kMainThreadName); |
666 | 676 |
667 const TrackedTime kTimePosted1 = TrackedTime::FromMilliseconds(9); | 677 const base::TimeTicks kTimePosted1 = base::TimeTicks::FromInternalValue(9000); |
668 const base::TimeTicks kDelayedStartTime1 = base::TimeTicks(); | 678 const base::TimeTicks kDelayedStartTime1 = base::TimeTicks(); |
669 // TrackingInfo will call TallyABirth() during construction. | 679 // TrackingInfo will call TallyABirth() during construction. |
670 base::TrackingInfo pending_task1(location, kDelayedStartTime1); | 680 base::TrackingInfo pending_task1(location, kDelayedStartTime1); |
671 pending_task1.time_posted = kTimePosted1; // Overwrite implied Now(). | 681 pending_task1.time_posted = kTimePosted1; // Overwrite implied Now(). |
672 | 682 |
673 const unsigned int kStartOfRun1 = 11; | 683 const unsigned int kStartOfRun1 = 11; |
674 const unsigned int kEndOfRun1 = 21; | 684 const unsigned int kEndOfRun1 = 21; |
675 SetTestTime(kStartOfRun1); | 685 SetTestTime(kStartOfRun1); |
676 TaskStopwatch stopwatch1; | 686 TaskStopwatch stopwatch1; |
677 stopwatch1.Start(); | 687 stopwatch1.Start(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); | 897 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); |
888 } | 898 } |
889 | 899 |
890 TEST_F(TrackedObjectsTest, TwoPhasesSecondEmpty) { | 900 TEST_F(TrackedObjectsTest, TwoPhasesSecondEmpty) { |
891 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 901 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
892 | 902 |
893 const char kFunction[] = "TwoPhasesSecondEmpty"; | 903 const char kFunction[] = "TwoPhasesSecondEmpty"; |
894 Location location(kFunction, kFile, kLineNumber, NULL); | 904 Location location(kFunction, kFile, kLineNumber, NULL); |
895 ThreadData::InitializeThreadContext(kMainThreadName); | 905 ThreadData::InitializeThreadContext(kMainThreadName); |
896 | 906 |
897 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 907 const base::TimeTicks kTimePosted = |
| 908 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
898 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 909 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
899 // TrackingInfo will call TallyABirth() during construction. | 910 // TrackingInfo will call TallyABirth() during construction. |
900 base::TrackingInfo pending_task(location, kDelayedStartTime); | 911 base::TrackingInfo pending_task(location, kDelayedStartTime); |
901 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 912 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
902 | 913 |
903 const unsigned int kStartOfRun = 5; | 914 const unsigned int kStartOfRun = 5; |
904 const unsigned int kEndOfRun = 7; | 915 const unsigned int kEndOfRun = 7; |
905 SetTestTime(kStartOfRun); | 916 SetTestTime(kStartOfRun); |
906 TaskStopwatch stopwatch; | 917 TaskStopwatch stopwatch; |
907 stopwatch.Start(); | 918 stopwatch.Start(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 | 965 |
955 TEST_F(TrackedObjectsTest, TwoPhasesFirstEmpty) { | 966 TEST_F(TrackedObjectsTest, TwoPhasesFirstEmpty) { |
956 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 967 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
957 | 968 |
958 ThreadData::OnProfilingPhaseCompleted(0); | 969 ThreadData::OnProfilingPhaseCompleted(0); |
959 | 970 |
960 const char kFunction[] = "TwoPhasesSecondEmpty"; | 971 const char kFunction[] = "TwoPhasesSecondEmpty"; |
961 Location location(kFunction, kFile, kLineNumber, NULL); | 972 Location location(kFunction, kFile, kLineNumber, NULL); |
962 ThreadData::InitializeThreadContext(kMainThreadName); | 973 ThreadData::InitializeThreadContext(kMainThreadName); |
963 | 974 |
964 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 975 const base::TimeTicks kTimePosted = |
| 976 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
965 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 977 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
966 // TrackingInfo will call TallyABirth() during construction. | 978 // TrackingInfo will call TallyABirth() during construction. |
967 base::TrackingInfo pending_task(location, kDelayedStartTime); | 979 base::TrackingInfo pending_task(location, kDelayedStartTime); |
968 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 980 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
969 | 981 |
970 const unsigned int kStartOfRun = 5; | 982 const unsigned int kStartOfRun = 5; |
971 const unsigned int kEndOfRun = 7; | 983 const unsigned int kEndOfRun = 7; |
972 SetTestTime(kStartOfRun); | 984 SetTestTime(kStartOfRun); |
973 TaskStopwatch stopwatch; | 985 TaskStopwatch stopwatch; |
974 stopwatch.Start(); | 986 stopwatch.Start(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 // demonstrate that the lifecycle is completely tallied. This ensures that | 1027 // demonstrate that the lifecycle is completely tallied. This ensures that |
1016 // our tallied births are matched by tallied deaths (except for when the | 1028 // our tallied births are matched by tallied deaths (except for when the |
1017 // task is still running, or is queued). | 1029 // task is still running, or is queued). |
1018 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) { | 1030 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) { |
1019 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1031 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1020 | 1032 |
1021 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread"; | 1033 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread"; |
1022 Location location(kFunction, kFile, kLineNumber, NULL); | 1034 Location location(kFunction, kFile, kLineNumber, NULL); |
1023 TallyABirth(location, kMainThreadName); | 1035 TallyABirth(location, kMainThreadName); |
1024 | 1036 |
1025 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1037 const base::TimeTicks kTimePosted = |
| 1038 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1026 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1039 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1027 // TrackingInfo will call TallyABirth() during construction. | 1040 // TrackingInfo will call TallyABirth() during construction. |
1028 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1041 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1029 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1042 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1030 | 1043 |
1031 // Turn off tracking now that we have births. | 1044 // Turn off tracking now that we have births. |
1032 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); | 1045 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); |
1033 | 1046 |
1034 const unsigned int kStartOfRun = 5; | 1047 const unsigned int kStartOfRun = 5; |
1035 const unsigned int kEndOfRun = 7; | 1048 const unsigned int kEndOfRun = 7; |
(...skipping 14 matching lines...) Expand all Loading... |
1050 // We will deactivate tracking before starting a life cycle, and neither | 1063 // We will deactivate tracking before starting a life cycle, and neither |
1051 // the birth nor the death will be recorded. | 1064 // the birth nor the death will be recorded. |
1052 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) { | 1065 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) { |
1053 // Start in the deactivated state. | 1066 // Start in the deactivated state. |
1054 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); | 1067 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); |
1055 | 1068 |
1056 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread"; | 1069 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread"; |
1057 Location location(kFunction, kFile, kLineNumber, NULL); | 1070 Location location(kFunction, kFile, kLineNumber, NULL); |
1058 TallyABirth(location, kMainThreadName); | 1071 TallyABirth(location, kMainThreadName); |
1059 | 1072 |
1060 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1073 const base::TimeTicks kTimePosted = |
| 1074 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1061 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1075 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1062 // TrackingInfo will call TallyABirth() during construction. | 1076 // TrackingInfo will call TallyABirth() during construction. |
1063 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1077 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1064 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1078 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1065 | 1079 |
1066 const unsigned int kStartOfRun = 5; | 1080 const unsigned int kStartOfRun = 5; |
1067 const unsigned int kEndOfRun = 7; | 1081 const unsigned int kEndOfRun = 7; |
1068 SetTestTime(kStartOfRun); | 1082 SetTestTime(kStartOfRun); |
1069 TaskStopwatch stopwatch; | 1083 TaskStopwatch stopwatch; |
1070 stopwatch.Start(); | 1084 stopwatch.Start(); |
(...skipping 16 matching lines...) Expand all Loading... |
1087 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); | 1101 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); |
1088 } | 1102 } |
1089 | 1103 |
1090 TEST_F(TrackedObjectsTest, TwoLives) { | 1104 TEST_F(TrackedObjectsTest, TwoLives) { |
1091 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1105 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1092 | 1106 |
1093 const char kFunction[] = "TwoLives"; | 1107 const char kFunction[] = "TwoLives"; |
1094 Location location(kFunction, kFile, kLineNumber, NULL); | 1108 Location location(kFunction, kFile, kLineNumber, NULL); |
1095 TallyABirth(location, kMainThreadName); | 1109 TallyABirth(location, kMainThreadName); |
1096 | 1110 |
1097 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1111 const base::TimeTicks kTimePosted = |
| 1112 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1098 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1113 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1099 // TrackingInfo will call TallyABirth() during construction. | 1114 // TrackingInfo will call TallyABirth() during construction. |
1100 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1115 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1101 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1116 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1102 | 1117 |
1103 const unsigned int kStartOfRun = 5; | 1118 const unsigned int kStartOfRun = 5; |
1104 const unsigned int kEndOfRun = 7; | 1119 const unsigned int kEndOfRun = 7; |
1105 SetTestTime(kStartOfRun); | 1120 SetTestTime(kStartOfRun); |
1106 TaskStopwatch stopwatch; | 1121 TaskStopwatch stopwatch; |
1107 stopwatch.Start(); | 1122 stopwatch.Start(); |
(...skipping 20 matching lines...) Expand all Loading... |
1128 } | 1143 } |
1129 | 1144 |
1130 TEST_F(TrackedObjectsTest, DifferentLives) { | 1145 TEST_F(TrackedObjectsTest, DifferentLives) { |
1131 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1146 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1132 | 1147 |
1133 // Use a well named thread. | 1148 // Use a well named thread. |
1134 ThreadData::InitializeThreadContext(kMainThreadName); | 1149 ThreadData::InitializeThreadContext(kMainThreadName); |
1135 const char kFunction[] = "DifferentLives"; | 1150 const char kFunction[] = "DifferentLives"; |
1136 Location location(kFunction, kFile, kLineNumber, NULL); | 1151 Location location(kFunction, kFile, kLineNumber, NULL); |
1137 | 1152 |
1138 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1153 const base::TimeTicks kTimePosted = |
| 1154 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1139 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1155 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1140 // TrackingInfo will call TallyABirth() during construction. | 1156 // TrackingInfo will call TallyABirth() during construction. |
1141 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1157 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1142 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1158 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1143 | 1159 |
1144 const unsigned int kStartOfRun = 5; | 1160 const unsigned int kStartOfRun = 5; |
1145 const unsigned int kEndOfRun = 7; | 1161 const unsigned int kEndOfRun = 7; |
1146 SetTestTime(kStartOfRun); | 1162 SetTestTime(kStartOfRun); |
1147 TaskStopwatch stopwatch; | 1163 TaskStopwatch stopwatch; |
1148 stopwatch.Start(); | 1164 stopwatch.Start(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); | 1219 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); |
1204 } | 1220 } |
1205 | 1221 |
1206 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) { | 1222 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) { |
1207 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1223 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1208 | 1224 |
1209 const char kFunction[] = "TaskWithNestedExclusion"; | 1225 const char kFunction[] = "TaskWithNestedExclusion"; |
1210 Location location(kFunction, kFile, kLineNumber, NULL); | 1226 Location location(kFunction, kFile, kLineNumber, NULL); |
1211 TallyABirth(location, kMainThreadName); | 1227 TallyABirth(location, kMainThreadName); |
1212 | 1228 |
1213 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1229 const base::TimeTicks kTimePosted = |
| 1230 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1214 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1231 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1215 // TrackingInfo will call TallyABirth() during construction. | 1232 // TrackingInfo will call TallyABirth() during construction. |
1216 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1233 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1217 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1234 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1218 | 1235 |
1219 SetTestTime(5); | 1236 SetTestTime(5); |
1220 TaskStopwatch task_stopwatch; | 1237 TaskStopwatch task_stopwatch; |
1221 task_stopwatch.Start(); | 1238 task_stopwatch.Start(); |
1222 { | 1239 { |
1223 SetTestTime(8); | 1240 SetTestTime(8); |
(...skipping 13 matching lines...) Expand all Loading... |
1237 kMainThreadName, 1, 6, 4); | 1254 kMainThreadName, 1, 6, 4); |
1238 } | 1255 } |
1239 | 1256 |
1240 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) { | 1257 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) { |
1241 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1258 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1242 | 1259 |
1243 const char kFunction[] = "TaskWith2NestedExclusions"; | 1260 const char kFunction[] = "TaskWith2NestedExclusions"; |
1244 Location location(kFunction, kFile, kLineNumber, NULL); | 1261 Location location(kFunction, kFile, kLineNumber, NULL); |
1245 TallyABirth(location, kMainThreadName); | 1262 TallyABirth(location, kMainThreadName); |
1246 | 1263 |
1247 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1264 const base::TimeTicks kTimePosted = |
| 1265 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1248 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1266 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1249 // TrackingInfo will call TallyABirth() during construction. | 1267 // TrackingInfo will call TallyABirth() during construction. |
1250 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1268 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1251 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1269 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1252 | 1270 |
1253 SetTestTime(5); | 1271 SetTestTime(5); |
1254 TaskStopwatch task_stopwatch; | 1272 TaskStopwatch task_stopwatch; |
1255 task_stopwatch.Start(); | 1273 task_stopwatch.Start(); |
1256 { | 1274 { |
1257 SetTestTime(8); | 1275 SetTestTime(8); |
(...skipping 22 matching lines...) Expand all Loading... |
1280 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) { | 1298 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) { |
1281 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 1299 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
1282 | 1300 |
1283 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask"; | 1301 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask"; |
1284 Location location(kFunction, kFile, kLineNumber, NULL); | 1302 Location location(kFunction, kFile, kLineNumber, NULL); |
1285 | 1303 |
1286 const int kSecondFakeLineNumber = 999; | 1304 const int kSecondFakeLineNumber = 999; |
1287 | 1305 |
1288 TallyABirth(location, kMainThreadName); | 1306 TallyABirth(location, kMainThreadName); |
1289 | 1307 |
1290 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); | 1308 const base::TimeTicks kTimePosted = |
| 1309 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1); |
1291 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); | 1310 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); |
1292 // TrackingInfo will call TallyABirth() during construction. | 1311 // TrackingInfo will call TallyABirth() during construction. |
1293 base::TrackingInfo pending_task(location, kDelayedStartTime); | 1312 base::TrackingInfo pending_task(location, kDelayedStartTime); |
1294 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). | 1313 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). |
1295 | 1314 |
1296 SetTestTime(5); | 1315 SetTestTime(5); |
1297 TaskStopwatch task_stopwatch; | 1316 TaskStopwatch task_stopwatch; |
1298 task_stopwatch.Start(); | 1317 task_stopwatch.Start(); |
1299 { | 1318 { |
1300 SetTestTime(8); | 1319 SetTestTime(8); |
1301 TaskStopwatch exclusion_stopwatch; | 1320 TaskStopwatch exclusion_stopwatch; |
1302 exclusion_stopwatch.Start(); | 1321 exclusion_stopwatch.Start(); |
1303 { | 1322 { |
1304 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL); | 1323 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL); |
1305 base::TrackingInfo nested_task(second_location, kDelayedStartTime); | 1324 base::TrackingInfo nested_task(second_location, kDelayedStartTime); |
1306 // Overwrite implied Now(). | 1325 // Overwrite implied Now(). |
1307 nested_task.time_posted = TrackedTime::FromMilliseconds(8); | 1326 nested_task.time_posted = |
| 1327 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8); |
1308 SetTestTime(9); | 1328 SetTestTime(9); |
1309 TaskStopwatch nested_task_stopwatch; | 1329 TaskStopwatch nested_task_stopwatch; |
1310 nested_task_stopwatch.Start(); | 1330 nested_task_stopwatch.Start(); |
1311 SetTestTime(11); | 1331 SetTestTime(11); |
1312 nested_task_stopwatch.Stop(); | 1332 nested_task_stopwatch.Stop(); |
1313 ThreadData::TallyRunOnNamedThreadIfTracking( | 1333 ThreadData::TallyRunOnNamedThreadIfTracking( |
1314 nested_task, nested_task_stopwatch); | 1334 nested_task, nested_task_stopwatch); |
1315 } | 1335 } |
1316 SetTestTime(12); | 1336 SetTestTime(12); |
1317 exclusion_stopwatch.Stop(); | 1337 exclusion_stopwatch.Stop(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 EXPECT_TRUE(thread.Start()); | 1407 EXPECT_TRUE(thread.Start()); |
1388 } | 1408 } |
1389 } | 1409 } |
1390 | 1410 |
1391 // Expect one ThreadData instance for each element in |kThreadNames| and one | 1411 // Expect one ThreadData instance for each element in |kThreadNames| and one |
1392 // ThreadData instance for the main thread. | 1412 // ThreadData instance for the main thread. |
1393 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); | 1413 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); |
1394 } | 1414 } |
1395 | 1415 |
1396 } // namespace tracked_objects | 1416 } // namespace tracked_objects |
OLD | NEW |