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

Side by Side Diff: base/tracked_objects_unittest.cc

Issue 2956683002: chrome://profiler infrastructure uses base time types. (Closed)
Patch Set: Fix test Created 3 years, 6 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
OLDNEW
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
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
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
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
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);
gab 2017/06/26 21:48:12 Why FromIntervalValue() here and elsewhere in this
tdresser 2017/06/27 13:21:56 Switched to base::TimeTicks() + base::TimeDelta::F
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
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 = base::TimeTicks::FromInternalValue(1000);
898 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 908 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
899 // TrackingInfo will call TallyABirth() during construction. 909 // TrackingInfo will call TallyABirth() during construction.
900 base::TrackingInfo pending_task(location, kDelayedStartTime); 910 base::TrackingInfo pending_task(location, kDelayedStartTime);
901 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 911 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
902 912
903 const unsigned int kStartOfRun = 5; 913 const unsigned int kStartOfRun = 5;
904 const unsigned int kEndOfRun = 7; 914 const unsigned int kEndOfRun = 7;
905 SetTestTime(kStartOfRun); 915 SetTestTime(kStartOfRun);
906 TaskStopwatch stopwatch; 916 TaskStopwatch stopwatch;
907 stopwatch.Start(); 917 stopwatch.Start();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 964
955 TEST_F(TrackedObjectsTest, TwoPhasesFirstEmpty) { 965 TEST_F(TrackedObjectsTest, TwoPhasesFirstEmpty) {
956 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 966 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
957 967
958 ThreadData::OnProfilingPhaseCompleted(0); 968 ThreadData::OnProfilingPhaseCompleted(0);
959 969
960 const char kFunction[] = "TwoPhasesSecondEmpty"; 970 const char kFunction[] = "TwoPhasesSecondEmpty";
961 Location location(kFunction, kFile, kLineNumber, NULL); 971 Location location(kFunction, kFile, kLineNumber, NULL);
962 ThreadData::InitializeThreadContext(kMainThreadName); 972 ThreadData::InitializeThreadContext(kMainThreadName);
963 973
964 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 974 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
965 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 975 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
966 // TrackingInfo will call TallyABirth() during construction. 976 // TrackingInfo will call TallyABirth() during construction.
967 base::TrackingInfo pending_task(location, kDelayedStartTime); 977 base::TrackingInfo pending_task(location, kDelayedStartTime);
968 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 978 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
969 979
970 const unsigned int kStartOfRun = 5; 980 const unsigned int kStartOfRun = 5;
971 const unsigned int kEndOfRun = 7; 981 const unsigned int kEndOfRun = 7;
972 SetTestTime(kStartOfRun); 982 SetTestTime(kStartOfRun);
973 TaskStopwatch stopwatch; 983 TaskStopwatch stopwatch;
974 stopwatch.Start(); 984 stopwatch.Start();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // demonstrate that the lifecycle is completely tallied. This ensures that 1025 // demonstrate that the lifecycle is completely tallied. This ensures that
1016 // our tallied births are matched by tallied deaths (except for when the 1026 // our tallied births are matched by tallied deaths (except for when the
1017 // task is still running, or is queued). 1027 // task is still running, or is queued).
1018 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) { 1028 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) {
1019 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1029 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1020 1030
1021 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread"; 1031 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread";
1022 Location location(kFunction, kFile, kLineNumber, NULL); 1032 Location location(kFunction, kFile, kLineNumber, NULL);
1023 TallyABirth(location, kMainThreadName); 1033 TallyABirth(location, kMainThreadName);
1024 1034
1025 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1035 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1026 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1036 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1027 // TrackingInfo will call TallyABirth() during construction. 1037 // TrackingInfo will call TallyABirth() during construction.
1028 base::TrackingInfo pending_task(location, kDelayedStartTime); 1038 base::TrackingInfo pending_task(location, kDelayedStartTime);
1029 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1039 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1030 1040
1031 // Turn off tracking now that we have births. 1041 // Turn off tracking now that we have births.
1032 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); 1042 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
1033 1043
1034 const unsigned int kStartOfRun = 5; 1044 const unsigned int kStartOfRun = 5;
1035 const unsigned int kEndOfRun = 7; 1045 const unsigned int kEndOfRun = 7;
(...skipping 14 matching lines...) Expand all
1050 // We will deactivate tracking before starting a life cycle, and neither 1060 // We will deactivate tracking before starting a life cycle, and neither
1051 // the birth nor the death will be recorded. 1061 // the birth nor the death will be recorded.
1052 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) { 1062 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) {
1053 // Start in the deactivated state. 1063 // Start in the deactivated state.
1054 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); 1064 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
1055 1065
1056 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread"; 1066 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread";
1057 Location location(kFunction, kFile, kLineNumber, NULL); 1067 Location location(kFunction, kFile, kLineNumber, NULL);
1058 TallyABirth(location, kMainThreadName); 1068 TallyABirth(location, kMainThreadName);
1059 1069
1060 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1070 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1061 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1071 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1062 // TrackingInfo will call TallyABirth() during construction. 1072 // TrackingInfo will call TallyABirth() during construction.
1063 base::TrackingInfo pending_task(location, kDelayedStartTime); 1073 base::TrackingInfo pending_task(location, kDelayedStartTime);
1064 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1074 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1065 1075
1066 const unsigned int kStartOfRun = 5; 1076 const unsigned int kStartOfRun = 5;
1067 const unsigned int kEndOfRun = 7; 1077 const unsigned int kEndOfRun = 7;
1068 SetTestTime(kStartOfRun); 1078 SetTestTime(kStartOfRun);
1069 TaskStopwatch stopwatch; 1079 TaskStopwatch stopwatch;
1070 stopwatch.Start(); 1080 stopwatch.Start();
(...skipping 16 matching lines...) Expand all
1087 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 1097 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
1088 } 1098 }
1089 1099
1090 TEST_F(TrackedObjectsTest, TwoLives) { 1100 TEST_F(TrackedObjectsTest, TwoLives) {
1091 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1101 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1092 1102
1093 const char kFunction[] = "TwoLives"; 1103 const char kFunction[] = "TwoLives";
1094 Location location(kFunction, kFile, kLineNumber, NULL); 1104 Location location(kFunction, kFile, kLineNumber, NULL);
1095 TallyABirth(location, kMainThreadName); 1105 TallyABirth(location, kMainThreadName);
1096 1106
1097 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1107 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1098 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1108 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1099 // TrackingInfo will call TallyABirth() during construction. 1109 // TrackingInfo will call TallyABirth() during construction.
1100 base::TrackingInfo pending_task(location, kDelayedStartTime); 1110 base::TrackingInfo pending_task(location, kDelayedStartTime);
1101 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1111 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1102 1112
1103 const unsigned int kStartOfRun = 5; 1113 const unsigned int kStartOfRun = 5;
1104 const unsigned int kEndOfRun = 7; 1114 const unsigned int kEndOfRun = 7;
1105 SetTestTime(kStartOfRun); 1115 SetTestTime(kStartOfRun);
1106 TaskStopwatch stopwatch; 1116 TaskStopwatch stopwatch;
1107 stopwatch.Start(); 1117 stopwatch.Start();
(...skipping 20 matching lines...) Expand all
1128 } 1138 }
1129 1139
1130 TEST_F(TrackedObjectsTest, DifferentLives) { 1140 TEST_F(TrackedObjectsTest, DifferentLives) {
1131 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1141 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1132 1142
1133 // Use a well named thread. 1143 // Use a well named thread.
1134 ThreadData::InitializeThreadContext(kMainThreadName); 1144 ThreadData::InitializeThreadContext(kMainThreadName);
1135 const char kFunction[] = "DifferentLives"; 1145 const char kFunction[] = "DifferentLives";
1136 Location location(kFunction, kFile, kLineNumber, NULL); 1146 Location location(kFunction, kFile, kLineNumber, NULL);
1137 1147
1138 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1148 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1139 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1149 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1140 // TrackingInfo will call TallyABirth() during construction. 1150 // TrackingInfo will call TallyABirth() during construction.
1141 base::TrackingInfo pending_task(location, kDelayedStartTime); 1151 base::TrackingInfo pending_task(location, kDelayedStartTime);
1142 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1152 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1143 1153
1144 const unsigned int kStartOfRun = 5; 1154 const unsigned int kStartOfRun = 5;
1145 const unsigned int kEndOfRun = 7; 1155 const unsigned int kEndOfRun = 7;
1146 SetTestTime(kStartOfRun); 1156 SetTestTime(kStartOfRun);
1147 TaskStopwatch stopwatch; 1157 TaskStopwatch stopwatch;
1148 stopwatch.Start(); 1158 stopwatch.Start();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 1213 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
1204 } 1214 }
1205 1215
1206 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) { 1216 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) {
1207 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1217 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1208 1218
1209 const char kFunction[] = "TaskWithNestedExclusion"; 1219 const char kFunction[] = "TaskWithNestedExclusion";
1210 Location location(kFunction, kFile, kLineNumber, NULL); 1220 Location location(kFunction, kFile, kLineNumber, NULL);
1211 TallyABirth(location, kMainThreadName); 1221 TallyABirth(location, kMainThreadName);
1212 1222
1213 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1223 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1214 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1224 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1215 // TrackingInfo will call TallyABirth() during construction. 1225 // TrackingInfo will call TallyABirth() during construction.
1216 base::TrackingInfo pending_task(location, kDelayedStartTime); 1226 base::TrackingInfo pending_task(location, kDelayedStartTime);
1217 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1227 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1218 1228
1219 SetTestTime(5); 1229 SetTestTime(5);
1220 TaskStopwatch task_stopwatch; 1230 TaskStopwatch task_stopwatch;
1221 task_stopwatch.Start(); 1231 task_stopwatch.Start();
1222 { 1232 {
1223 SetTestTime(8); 1233 SetTestTime(8);
(...skipping 13 matching lines...) Expand all
1237 kMainThreadName, 1, 6, 4); 1247 kMainThreadName, 1, 6, 4);
1238 } 1248 }
1239 1249
1240 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) { 1250 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) {
1241 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1251 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1242 1252
1243 const char kFunction[] = "TaskWith2NestedExclusions"; 1253 const char kFunction[] = "TaskWith2NestedExclusions";
1244 Location location(kFunction, kFile, kLineNumber, NULL); 1254 Location location(kFunction, kFile, kLineNumber, NULL);
1245 TallyABirth(location, kMainThreadName); 1255 TallyABirth(location, kMainThreadName);
1246 1256
1247 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1257 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1248 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1258 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1249 // TrackingInfo will call TallyABirth() during construction. 1259 // TrackingInfo will call TallyABirth() during construction.
1250 base::TrackingInfo pending_task(location, kDelayedStartTime); 1260 base::TrackingInfo pending_task(location, kDelayedStartTime);
1251 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1261 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1252 1262
1253 SetTestTime(5); 1263 SetTestTime(5);
1254 TaskStopwatch task_stopwatch; 1264 TaskStopwatch task_stopwatch;
1255 task_stopwatch.Start(); 1265 task_stopwatch.Start();
1256 { 1266 {
1257 SetTestTime(8); 1267 SetTestTime(8);
(...skipping 22 matching lines...) Expand all
1280 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) { 1290 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) {
1281 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); 1291 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
1282 1292
1283 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask"; 1293 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask";
1284 Location location(kFunction, kFile, kLineNumber, NULL); 1294 Location location(kFunction, kFile, kLineNumber, NULL);
1285 1295
1286 const int kSecondFakeLineNumber = 999; 1296 const int kSecondFakeLineNumber = 999;
1287 1297
1288 TallyABirth(location, kMainThreadName); 1298 TallyABirth(location, kMainThreadName);
1289 1299
1290 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1300 const base::TimeTicks kTimePosted = base::TimeTicks::FromInternalValue(1000);
1291 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1301 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
1292 // TrackingInfo will call TallyABirth() during construction. 1302 // TrackingInfo will call TallyABirth() during construction.
1293 base::TrackingInfo pending_task(location, kDelayedStartTime); 1303 base::TrackingInfo pending_task(location, kDelayedStartTime);
1294 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1304 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
1295 1305
1296 SetTestTime(5); 1306 SetTestTime(5);
1297 TaskStopwatch task_stopwatch; 1307 TaskStopwatch task_stopwatch;
1298 task_stopwatch.Start(); 1308 task_stopwatch.Start();
1299 { 1309 {
1300 SetTestTime(8); 1310 SetTestTime(8);
1301 TaskStopwatch exclusion_stopwatch; 1311 TaskStopwatch exclusion_stopwatch;
1302 exclusion_stopwatch.Start(); 1312 exclusion_stopwatch.Start();
1303 { 1313 {
1304 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL); 1314 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL);
1305 base::TrackingInfo nested_task(second_location, kDelayedStartTime); 1315 base::TrackingInfo nested_task(second_location, kDelayedStartTime);
1306 // Overwrite implied Now(). 1316 // Overwrite implied Now().
1307 nested_task.time_posted = TrackedTime::FromMilliseconds(8); 1317 nested_task.time_posted = base::TimeTicks::FromInternalValue(8000);
1308 SetTestTime(9); 1318 SetTestTime(9);
1309 TaskStopwatch nested_task_stopwatch; 1319 TaskStopwatch nested_task_stopwatch;
1310 nested_task_stopwatch.Start(); 1320 nested_task_stopwatch.Start();
1311 SetTestTime(11); 1321 SetTestTime(11);
1312 nested_task_stopwatch.Stop(); 1322 nested_task_stopwatch.Stop();
1313 ThreadData::TallyRunOnNamedThreadIfTracking( 1323 ThreadData::TallyRunOnNamedThreadIfTracking(
1314 nested_task, nested_task_stopwatch); 1324 nested_task, nested_task_stopwatch);
1315 } 1325 }
1316 SetTestTime(12); 1326 SetTestTime(12);
1317 exclusion_stopwatch.Stop(); 1327 exclusion_stopwatch.Stop();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 EXPECT_TRUE(thread.Start()); 1397 EXPECT_TRUE(thread.Start());
1388 } 1398 }
1389 } 1399 }
1390 1400
1391 // Expect one ThreadData instance for each element in |kThreadNames| and one 1401 // Expect one ThreadData instance for each element in |kThreadNames| and one
1392 // ThreadData instance for the main thread. 1402 // ThreadData instance for the main thread.
1393 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); 1403 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData());
1394 } 1404 }
1395 1405
1396 } // namespace tracked_objects 1406 } // namespace tracked_objects
OLDNEW
« base/tracked_objects.cc ('K') | « base/tracked_objects.cc ('k') | base/tracking_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698