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

Side by Side Diff: base/tracked_objects_unittest.cc

Issue 985773002: Introducing phased profiling framework (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write_to_file
Patch Set: Fixing Android compile errors. Created 5 years, 8 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
« no previous file with comments | « base/tracked_objects.cc ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 // Helper function to verify the most common test expectations. 66 // Helper function to verify the most common test expectations.
67 void ExpectSimpleProcessData(const ProcessDataSnapshot& process_data, 67 void ExpectSimpleProcessData(const ProcessDataSnapshot& process_data,
68 const std::string& function_name, 68 const std::string& function_name,
69 const std::string& birth_thread, 69 const std::string& birth_thread,
70 const std::string& death_thread, 70 const std::string& death_thread,
71 int count, 71 int count,
72 int run_ms, 72 int run_ms,
73 int queue_ms) { 73 int queue_ms) {
74 ASSERT_EQ(1u, process_data.tasks.size()); 74 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
75 auto it = process_data.phased_process_data_snapshots.find(0);
76 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
77 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
75 78
76 EXPECT_EQ(kFile, process_data.tasks[0].birth.location.file_name); 79 ASSERT_EQ(1u, process_data_phase.tasks.size());
80
81 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name);
77 EXPECT_EQ(function_name, 82 EXPECT_EQ(function_name,
78 process_data.tasks[0].birth.location.function_name); 83 process_data_phase.tasks[0].birth.location.function_name);
79 EXPECT_EQ(kLineNumber, process_data.tasks[0].birth.location.line_number); 84 EXPECT_EQ(kLineNumber,
85 process_data_phase.tasks[0].birth.location.line_number);
80 86
81 EXPECT_EQ(birth_thread, process_data.tasks[0].birth.thread_name); 87 EXPECT_EQ(birth_thread, process_data_phase.tasks[0].birth.thread_name);
82 88
83 EXPECT_EQ(count, process_data.tasks[0].death_data.count); 89 EXPECT_EQ(count, process_data_phase.tasks[0].death_data.count);
84 EXPECT_EQ(count * run_ms, 90 EXPECT_EQ(count * run_ms,
85 process_data.tasks[0].death_data.run_duration_sum); 91 process_data_phase.tasks[0].death_data.run_duration_sum);
86 EXPECT_EQ(run_ms, process_data.tasks[0].death_data.run_duration_max); 92 EXPECT_EQ(run_ms, process_data_phase.tasks[0].death_data.run_duration_max);
87 EXPECT_EQ(run_ms, process_data.tasks[0].death_data.run_duration_sample); 93 EXPECT_EQ(run_ms,
94 process_data_phase.tasks[0].death_data.run_duration_sample);
88 EXPECT_EQ(count * queue_ms, 95 EXPECT_EQ(count * queue_ms,
89 process_data.tasks[0].death_data.queue_duration_sum); 96 process_data_phase.tasks[0].death_data.queue_duration_sum);
90 EXPECT_EQ(queue_ms, process_data.tasks[0].death_data.queue_duration_max); 97 EXPECT_EQ(queue_ms,
91 EXPECT_EQ(queue_ms, process_data.tasks[0].death_data.queue_duration_sample); 98 process_data_phase.tasks[0].death_data.queue_duration_max);
99 EXPECT_EQ(queue_ms,
100 process_data_phase.tasks[0].death_data.queue_duration_sample);
92 101
93 EXPECT_EQ(death_thread, process_data.tasks[0].death_thread_name); 102 EXPECT_EQ(death_thread, process_data_phase.tasks[0].death_thread_name);
94 103
95 EXPECT_EQ(0u, process_data.descendants.size()); 104 EXPECT_EQ(0u, process_data_phase.descendants.size());
96 105
97 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 106 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
98 } 107 }
99 108
100 // Sets time that will be returned by ThreadData::Now(). 109 // Sets time that will be returned by ThreadData::Now().
101 static void SetTestTime(unsigned int test_time) { test_time_ = test_time; } 110 static void SetTestTime(unsigned int test_time) { test_time_ = test_time; }
102 111
103 private: 112 private:
104 // Returns test time in milliseconds. 113 // Returns test time in milliseconds.
105 static unsigned int GetTestTime() { return test_time_; } 114 static unsigned int GetTestTime() { return test_time_; }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } else { 232 } else {
224 EXPECT_EQ(0u, parent_child_set.size()); // no stats. 233 EXPECT_EQ(0u, parent_child_set.size()); // no stats.
225 } 234 }
226 235
227 // The births were at the same location as the one known death. 236 // The births were at the same location as the one known death.
228 EXPECT_EQ(birth_map.begin()->second, death_map.begin()->first); 237 EXPECT_EQ(birth_map.begin()->second, death_map.begin()->first);
229 238
230 ProcessDataSnapshot process_data; 239 ProcessDataSnapshot process_data;
231 ThreadData::Snapshot(&process_data); 240 ThreadData::Snapshot(&process_data);
232 241
233 ASSERT_EQ(1u, process_data.tasks.size()); 242 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
234 EXPECT_EQ(kFile, process_data.tasks[0].birth.location.file_name); 243 auto it = process_data.phased_process_data_snapshots.find(0);
235 EXPECT_EQ(kFunction, process_data.tasks[0].birth.location.function_name); 244 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
236 EXPECT_EQ(kLineNumber, process_data.tasks[0].birth.location.line_number); 245 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
237 EXPECT_EQ(kWorkerThreadName, process_data.tasks[0].birth.thread_name); 246 ASSERT_EQ(1u, process_data_phase.tasks.size());
238 EXPECT_EQ(1, process_data.tasks[0].death_data.count); 247 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name);
239 EXPECT_EQ(time_elapsed, process_data.tasks[0].death_data.run_duration_sum); 248 EXPECT_EQ(kFunction,
240 EXPECT_EQ(time_elapsed, process_data.tasks[0].death_data.run_duration_max); 249 process_data_phase.tasks[0].birth.location.function_name);
241 EXPECT_EQ(time_elapsed, process_data.tasks[0].death_data.run_duration_sample); 250 EXPECT_EQ(kLineNumber,
242 EXPECT_EQ(0, process_data.tasks[0].death_data.queue_duration_sum); 251 process_data_phase.tasks[0].birth.location.line_number);
243 EXPECT_EQ(0, process_data.tasks[0].death_data.queue_duration_max); 252 EXPECT_EQ(kWorkerThreadName, process_data_phase.tasks[0].birth.thread_name);
244 EXPECT_EQ(0, process_data.tasks[0].death_data.queue_duration_sample); 253 EXPECT_EQ(1, process_data_phase.tasks[0].death_data.count);
245 EXPECT_EQ(kWorkerThreadName, process_data.tasks[0].death_thread_name); 254 EXPECT_EQ(time_elapsed,
255 process_data_phase.tasks[0].death_data.run_duration_sum);
256 EXPECT_EQ(time_elapsed,
257 process_data_phase.tasks[0].death_data.run_duration_max);
258 EXPECT_EQ(time_elapsed,
259 process_data_phase.tasks[0].death_data.run_duration_sample);
260 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sum);
261 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_max);
262 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sample);
263 EXPECT_EQ(kWorkerThreadName, process_data_phase.tasks[0].death_thread_name);
246 264
247 if (ThreadData::TrackingParentChildStatus()) { 265 if (ThreadData::TrackingParentChildStatus()) {
248 ASSERT_EQ(1u, process_data.descendants.size()); 266 ASSERT_EQ(1u, process_data_phase.descendants.size());
249 EXPECT_EQ(kFile, process_data.descendants[0].parent.location.file_name); 267 EXPECT_EQ(kFile,
268 process_data_phase.descendants[0].parent.location.file_name);
250 EXPECT_EQ(kFunction, 269 EXPECT_EQ(kFunction,
251 process_data.descendants[0].parent.location.function_name); 270 process_data_phase.descendants[0].parent.location.function_name);
252 EXPECT_EQ(kLineNumber, 271 EXPECT_EQ(kLineNumber,
253 process_data.descendants[0].parent.location.line_number); 272 process_data_phase.descendants[0].parent.location.line_number);
254 EXPECT_EQ(kWorkerThreadName, 273 EXPECT_EQ(kWorkerThreadName,
255 process_data.descendants[0].parent.thread_name); 274 process_data_phase.descendants[0].parent.thread_name);
256 EXPECT_EQ(kFile, process_data.descendants[0].child.location.file_name); 275 EXPECT_EQ(kFile,
276 process_data_phase.descendants[0].child.location.file_name);
257 EXPECT_EQ(kFunction, 277 EXPECT_EQ(kFunction,
258 process_data.descendants[0].child.location.function_name); 278 process_data_phase.descendants[0].child.location.function_name);
259 EXPECT_EQ(kLineNumber, 279 EXPECT_EQ(kLineNumber,
260 process_data.descendants[0].child.location.line_number); 280 process_data_phase.descendants[0].child.location.line_number);
261 EXPECT_EQ(kWorkerThreadName, process_data.descendants[0].child.thread_name); 281 EXPECT_EQ(kWorkerThreadName,
282 process_data_phase.descendants[0].child.thread_name);
262 } else { 283 } else {
263 EXPECT_EQ(0u, process_data.descendants.size()); 284 EXPECT_EQ(0u, process_data_phase.descendants.size());
264 } 285 }
265 } 286 }
266 287
267 TEST_F(TrackedObjectsTest, DeathDataTest) { 288 TEST_F(TrackedObjectsTest, DeathDataTest) {
268 if (!ThreadData::InitializeAndSetTrackingStatus( 289 if (!ThreadData::InitializeAndSetTrackingStatus(
269 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 290 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
270 return; 291 return;
271 } 292 }
272 293
273 scoped_ptr<DeathData> data(new DeathData()); 294 scoped_ptr<DeathData> data(new DeathData());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) { 332 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) {
312 return; 333 return;
313 } 334 }
314 335
315 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread"; 336 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread";
316 Location location(kFunction, kFile, kLineNumber, NULL); 337 Location location(kFunction, kFile, kLineNumber, NULL);
317 TallyABirth(location, std::string()); 338 TallyABirth(location, std::string());
318 339
319 ProcessDataSnapshot process_data; 340 ProcessDataSnapshot process_data;
320 ThreadData::Snapshot(&process_data); 341 ThreadData::Snapshot(&process_data);
321 EXPECT_EQ(0u, process_data.tasks.size()); 342
322 EXPECT_EQ(0u, process_data.descendants.size()); 343 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
344 auto it = process_data.phased_process_data_snapshots.find(0);
345 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
346 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
347
348 EXPECT_EQ(0u, process_data_phase.tasks.size());
349 EXPECT_EQ(0u, process_data_phase.descendants.size());
323 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 350 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
324 } 351 }
325 352
326 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) { 353 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) {
327 // Start in the deactivated state. 354 // Start in the deactivated state.
328 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) { 355 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) {
329 return; 356 return;
330 } 357 }
331 358
332 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread"; 359 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread";
333 Location location(kFunction, kFile, kLineNumber, NULL); 360 Location location(kFunction, kFile, kLineNumber, NULL);
334 TallyABirth(location, kMainThreadName); 361 TallyABirth(location, kMainThreadName);
335 362
336 ProcessDataSnapshot process_data; 363 ProcessDataSnapshot process_data;
337 ThreadData::Snapshot(&process_data); 364 ThreadData::Snapshot(&process_data);
338 EXPECT_EQ(0u, process_data.tasks.size()); 365
339 EXPECT_EQ(0u, process_data.descendants.size()); 366 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
367 auto it = process_data.phased_process_data_snapshots.find(0);
368 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
369 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
370
371 EXPECT_EQ(0u, process_data_phase.tasks.size());
372 EXPECT_EQ(0u, process_data_phase.descendants.size());
340 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 373 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
341 } 374 }
342 375
343 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) { 376 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) {
344 if (!ThreadData::InitializeAndSetTrackingStatus( 377 if (!ThreadData::InitializeAndSetTrackingStatus(
345 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 378 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
346 return; 379 return;
347 } 380 }
348 381
349 const char kFunction[] = "BirthOnlyToSnapshotWorkerThread"; 382 const char kFunction[] = "BirthOnlyToSnapshotWorkerThread";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Location location(kFunction, kFile, kLineNumber, NULL); 451 Location location(kFunction, kFile, kLineNumber, NULL);
419 TallyABirth(location, kMainThreadName); 452 TallyABirth(location, kMainThreadName);
420 453
421 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 454 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
422 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 455 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
423 // TrackingInfo will call TallyABirth() during construction. 456 // TrackingInfo will call TallyABirth() during construction.
424 base::TrackingInfo pending_task(location, kDelayedStartTime); 457 base::TrackingInfo pending_task(location, kDelayedStartTime);
425 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 458 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
426 459
427 // Turn off tracking now that we have births. 460 // Turn off tracking now that we have births.
428 EXPECT_TRUE(ThreadData::InitializeAndSetTrackingStatus( 461 EXPECT_TRUE(
429 ThreadData::DEACTIVATED)); 462 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED));
430 463
431 const unsigned int kStartOfRun = 5; 464 const unsigned int kStartOfRun = 5;
432 const unsigned int kEndOfRun = 7; 465 const unsigned int kEndOfRun = 7;
433 SetTestTime(kStartOfRun); 466 SetTestTime(kStartOfRun);
434 TaskStopwatch stopwatch; 467 TaskStopwatch stopwatch;
435 stopwatch.Start(); 468 stopwatch.Start();
436 SetTestTime(kEndOfRun); 469 SetTestTime(kEndOfRun);
437 stopwatch.Stop(); 470 stopwatch.Stop();
438 471
439 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 472 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
(...skipping 27 matching lines...) Expand all
467 SetTestTime(kStartOfRun); 500 SetTestTime(kStartOfRun);
468 TaskStopwatch stopwatch; 501 TaskStopwatch stopwatch;
469 stopwatch.Start(); 502 stopwatch.Start();
470 SetTestTime(kEndOfRun); 503 SetTestTime(kEndOfRun);
471 stopwatch.Stop(); 504 stopwatch.Stop();
472 505
473 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 506 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
474 507
475 ProcessDataSnapshot process_data; 508 ProcessDataSnapshot process_data;
476 ThreadData::Snapshot(&process_data); 509 ThreadData::Snapshot(&process_data);
477 EXPECT_EQ(0u, process_data.tasks.size()); 510
478 EXPECT_EQ(0u, process_data.descendants.size()); 511 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
512 auto it = process_data.phased_process_data_snapshots.find(0);
513 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
514 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
515
516 EXPECT_EQ(0u, process_data_phase.tasks.size());
517 EXPECT_EQ(0u, process_data_phase.descendants.size());
479 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 518 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
480 } 519 }
481 520
482 TEST_F(TrackedObjectsTest, TwoLives) { 521 TEST_F(TrackedObjectsTest, TwoLives) {
483 if (!ThreadData::InitializeAndSetTrackingStatus( 522 if (!ThreadData::InitializeAndSetTrackingStatus(
484 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 523 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
485 return; 524 return;
486 } 525 }
487 526
488 const char kFunction[] = "TwoLives"; 527 const char kFunction[] = "TwoLives";
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 590
552 const int kSecondFakeLineNumber = 999; 591 const int kSecondFakeLineNumber = 999;
553 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL); 592 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL);
554 593
555 // TrackingInfo will call TallyABirth() during construction. 594 // TrackingInfo will call TallyABirth() during construction.
556 base::TrackingInfo pending_task2(second_location, kDelayedStartTime); 595 base::TrackingInfo pending_task2(second_location, kDelayedStartTime);
557 pending_task2.time_posted = kTimePosted; // Overwrite implied Now(). 596 pending_task2.time_posted = kTimePosted; // Overwrite implied Now().
558 597
559 ProcessDataSnapshot process_data; 598 ProcessDataSnapshot process_data;
560 ThreadData::Snapshot(&process_data); 599 ThreadData::Snapshot(&process_data);
561 ASSERT_EQ(2u, process_data.tasks.size());
562 600
563 EXPECT_EQ(kFile, process_data.tasks[0].birth.location.file_name); 601 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
564 EXPECT_EQ(kFunction, process_data.tasks[0].birth.location.function_name); 602 auto it = process_data.phased_process_data_snapshots.find(0);
565 EXPECT_EQ(kLineNumber, process_data.tasks[0].birth.location.line_number); 603 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
566 EXPECT_EQ(kMainThreadName, process_data.tasks[0].birth.thread_name); 604 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
567 EXPECT_EQ(1, process_data.tasks[0].death_data.count); 605
568 EXPECT_EQ(2, process_data.tasks[0].death_data.run_duration_sum); 606 ASSERT_EQ(2u, process_data_phase.tasks.size());
569 EXPECT_EQ(2, process_data.tasks[0].death_data.run_duration_max); 607
570 EXPECT_EQ(2, process_data.tasks[0].death_data.run_duration_sample); 608 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name);
571 EXPECT_EQ(4, process_data.tasks[0].death_data.queue_duration_sum); 609 EXPECT_EQ(kFunction,
572 EXPECT_EQ(4, process_data.tasks[0].death_data.queue_duration_max); 610 process_data_phase.tasks[0].birth.location.function_name);
573 EXPECT_EQ(4, process_data.tasks[0].death_data.queue_duration_sample); 611 EXPECT_EQ(kLineNumber,
574 EXPECT_EQ(kMainThreadName, process_data.tasks[0].death_thread_name); 612 process_data_phase.tasks[0].birth.location.line_number);
575 EXPECT_EQ(kFile, process_data.tasks[1].birth.location.file_name); 613 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[0].birth.thread_name);
576 EXPECT_EQ(kFunction, process_data.tasks[1].birth.location.function_name); 614 EXPECT_EQ(1, process_data_phase.tasks[0].death_data.count);
615 EXPECT_EQ(2, process_data_phase.tasks[0].death_data.run_duration_sum);
616 EXPECT_EQ(2, process_data_phase.tasks[0].death_data.run_duration_max);
617 EXPECT_EQ(2, process_data_phase.tasks[0].death_data.run_duration_sample);
618 EXPECT_EQ(4, process_data_phase.tasks[0].death_data.queue_duration_sum);
619 EXPECT_EQ(4, process_data_phase.tasks[0].death_data.queue_duration_max);
620 EXPECT_EQ(4, process_data_phase.tasks[0].death_data.queue_duration_sample);
621 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[0].death_thread_name);
622 EXPECT_EQ(kFile, process_data_phase.tasks[1].birth.location.file_name);
623 EXPECT_EQ(kFunction,
624 process_data_phase.tasks[1].birth.location.function_name);
577 EXPECT_EQ(kSecondFakeLineNumber, 625 EXPECT_EQ(kSecondFakeLineNumber,
578 process_data.tasks[1].birth.location.line_number); 626 process_data_phase.tasks[1].birth.location.line_number);
579 EXPECT_EQ(kMainThreadName, process_data.tasks[1].birth.thread_name); 627 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[1].birth.thread_name);
580 EXPECT_EQ(1, process_data.tasks[1].death_data.count); 628 EXPECT_EQ(1, process_data_phase.tasks[1].death_data.count);
581 EXPECT_EQ(0, process_data.tasks[1].death_data.run_duration_sum); 629 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.run_duration_sum);
582 EXPECT_EQ(0, process_data.tasks[1].death_data.run_duration_max); 630 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.run_duration_max);
583 EXPECT_EQ(0, process_data.tasks[1].death_data.run_duration_sample); 631 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.run_duration_sample);
584 EXPECT_EQ(0, process_data.tasks[1].death_data.queue_duration_sum); 632 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_sum);
585 EXPECT_EQ(0, process_data.tasks[1].death_data.queue_duration_max); 633 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_max);
586 EXPECT_EQ(0, process_data.tasks[1].death_data.queue_duration_sample); 634 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_sample);
587 EXPECT_EQ(kStillAlive, process_data.tasks[1].death_thread_name); 635 EXPECT_EQ(kStillAlive, process_data_phase.tasks[1].death_thread_name);
588 EXPECT_EQ(0u, process_data.descendants.size()); 636 EXPECT_EQ(0u, process_data_phase.descendants.size());
589 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 637 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
590 } 638 }
591 639
592 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) { 640 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) {
593 if (!ThreadData::InitializeAndSetTrackingStatus( 641 if (!ThreadData::InitializeAndSetTrackingStatus(
594 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 642 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
595 return; 643 return;
596 } 644 }
597 645
598 const char kFunction[] = "TaskWithNestedExclusion"; 646 const char kFunction[] = "TaskWithNestedExclusion";
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 exclusion_stopwatch.Stop(); 760 exclusion_stopwatch.Stop();
713 } 761 }
714 SetTestTime(15); 762 SetTestTime(15);
715 task_stopwatch.Stop(); 763 task_stopwatch.Stop();
716 764
717 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch); 765 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch);
718 766
719 ProcessDataSnapshot process_data; 767 ProcessDataSnapshot process_data;
720 ThreadData::Snapshot(&process_data); 768 ThreadData::Snapshot(&process_data);
721 769
770 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
771 auto it = process_data.phased_process_data_snapshots.find(0);
772 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
773 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
774
722 // The order in which the two task follow is platform-dependent. 775 // The order in which the two task follow is platform-dependent.
723 int t0 = (process_data.tasks[0].birth.location.line_number == kLineNumber) ? 776 int t0 =
724 0 : 1; 777 (process_data_phase.tasks[0].birth.location.line_number == kLineNumber)
778 ? 0
779 : 1;
725 int t1 = 1 - t0; 780 int t1 = 1 - t0;
726 781
727 ASSERT_EQ(2u, process_data.tasks.size()); 782 ASSERT_EQ(2u, process_data_phase.tasks.size());
728 EXPECT_EQ(kFile, process_data.tasks[t0].birth.location.file_name); 783 EXPECT_EQ(kFile, process_data_phase.tasks[t0].birth.location.file_name);
729 EXPECT_EQ(kFunction, process_data.tasks[t0].birth.location.function_name); 784 EXPECT_EQ(kFunction,
730 EXPECT_EQ(kLineNumber, process_data.tasks[t0].birth.location.line_number); 785 process_data_phase.tasks[t0].birth.location.function_name);
731 EXPECT_EQ(kMainThreadName, process_data.tasks[t0].birth.thread_name); 786 EXPECT_EQ(kLineNumber,
732 EXPECT_EQ(1, process_data.tasks[t0].death_data.count); 787 process_data_phase.tasks[t0].birth.location.line_number);
733 EXPECT_EQ(6, process_data.tasks[t0].death_data.run_duration_sum); 788 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t0].birth.thread_name);
734 EXPECT_EQ(6, process_data.tasks[t0].death_data.run_duration_max); 789 EXPECT_EQ(1, process_data_phase.tasks[t0].death_data.count);
735 EXPECT_EQ(6, process_data.tasks[t0].death_data.run_duration_sample); 790 EXPECT_EQ(6, process_data_phase.tasks[t0].death_data.run_duration_sum);
736 EXPECT_EQ(4, process_data.tasks[t0].death_data.queue_duration_sum); 791 EXPECT_EQ(6, process_data_phase.tasks[t0].death_data.run_duration_max);
737 EXPECT_EQ(4, process_data.tasks[t0].death_data.queue_duration_max); 792 EXPECT_EQ(6, process_data_phase.tasks[t0].death_data.run_duration_sample);
738 EXPECT_EQ(4, process_data.tasks[t0].death_data.queue_duration_sample); 793 EXPECT_EQ(4, process_data_phase.tasks[t0].death_data.queue_duration_sum);
739 EXPECT_EQ(kMainThreadName, process_data.tasks[t0].death_thread_name); 794 EXPECT_EQ(4, process_data_phase.tasks[t0].death_data.queue_duration_max);
740 EXPECT_EQ(kFile, process_data.tasks[t1].birth.location.file_name); 795 EXPECT_EQ(4, process_data_phase.tasks[t0].death_data.queue_duration_sample);
741 EXPECT_EQ(kFunction, process_data.tasks[t1].birth.location.function_name); 796 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t0].death_thread_name);
797 EXPECT_EQ(kFile, process_data_phase.tasks[t1].birth.location.file_name);
798 EXPECT_EQ(kFunction,
799 process_data_phase.tasks[t1].birth.location.function_name);
742 EXPECT_EQ(kSecondFakeLineNumber, 800 EXPECT_EQ(kSecondFakeLineNumber,
743 process_data.tasks[t1].birth.location.line_number); 801 process_data_phase.tasks[t1].birth.location.line_number);
744 EXPECT_EQ(kMainThreadName, process_data.tasks[t1].birth.thread_name); 802 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].birth.thread_name);
745 EXPECT_EQ(1, process_data.tasks[t1].death_data.count); 803 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.count);
746 EXPECT_EQ(2, process_data.tasks[t1].death_data.run_duration_sum); 804 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sum);
747 EXPECT_EQ(2, process_data.tasks[t1].death_data.run_duration_max); 805 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_max);
748 EXPECT_EQ(2, process_data.tasks[t1].death_data.run_duration_sample); 806 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sample);
749 EXPECT_EQ(1, process_data.tasks[t1].death_data.queue_duration_sum); 807 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sum);
750 EXPECT_EQ(1, process_data.tasks[t1].death_data.queue_duration_max); 808 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_max);
751 EXPECT_EQ(1, process_data.tasks[t1].death_data.queue_duration_sample); 809 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sample);
752 EXPECT_EQ(kMainThreadName, process_data.tasks[t1].death_thread_name); 810 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].death_thread_name);
753 EXPECT_EQ(0u, process_data.descendants.size()); 811 EXPECT_EQ(0u, process_data_phase.descendants.size());
754 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 812 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
755 } 813 }
756 814
757 } // namespace tracked_objects 815 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked_objects.cc ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698