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

Side by Side Diff: base/tracked_objects_unittest.cc

Issue 1021053003: Delivering the FIRST_NONEMPTY_PAINT phase changing event to base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@phase_splitting
Patch Set: More isherman@ comments. 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Test time in milliseconds. 116 // Test time in milliseconds.
117 static unsigned int test_time_; 117 static unsigned int test_time_;
118 }; 118 };
119 119
120 // static 120 // static
121 unsigned int TrackedObjectsTest::test_time_; 121 unsigned int TrackedObjectsTest::test_time_;
122 122
123 TEST_F(TrackedObjectsTest, TaskStopwatchNoStartStop) { 123 TEST_F(TrackedObjectsTest, TaskStopwatchNoStartStop) {
124 if (!ThreadData::InitializeAndSetTrackingStatus( 124 if (!ThreadData::InitializeAndSetTrackingStatus(
125 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 125 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
126 // Don't run the test if task tracking is not compiled in.
126 return; 127 return;
127 } 128 }
128 129
129 // Check that creating and destroying a stopwatch without starting it doesn't 130 // Check that creating and destroying a stopwatch without starting it doesn't
130 // crash. 131 // crash.
131 TaskStopwatch stopwatch; 132 TaskStopwatch stopwatch;
132 } 133 }
133 134
134 TEST_F(TrackedObjectsTest, MinimalStartupShutdown) { 135 TEST_F(TrackedObjectsTest, MinimalStartupShutdown) {
135 // Minimal test doesn't even create any tasks. 136 // Minimal test doesn't even create any tasks.
136 if (!ThreadData::InitializeAndSetTrackingStatus( 137 if (!ThreadData::InitializeAndSetTrackingStatus(
137 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 138 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
139 // Don't run the test if task tracking is not compiled in.
138 return; 140 return;
139 } 141 }
140 142
141 EXPECT_FALSE(ThreadData::first()); // No activity even on this thread. 143 EXPECT_FALSE(ThreadData::first()); // No activity even on this thread.
142 ThreadData* data = ThreadData::Get(); 144 ThreadData* data = ThreadData::Get();
143 EXPECT_TRUE(ThreadData::first()); // Now class was constructed. 145 EXPECT_TRUE(ThreadData::first()); // Now class was constructed.
144 ASSERT_TRUE(data); 146 ASSERT_TRUE(data);
145 EXPECT_FALSE(data->next()); 147 EXPECT_FALSE(data->next());
146 EXPECT_EQ(data, ThreadData::Get()); 148 EXPECT_EQ(data, ThreadData::Get());
147 ThreadData::BirthMap birth_map; 149 ThreadData::BirthMap birth_map;
148 ThreadData::DeathMap death_map; 150 ThreadData::DeathsSnapshot deaths;
149 ThreadData::ParentChildSet parent_child_set; 151 ThreadData::ParentChildSet parent_child_set;
150 data->SnapshotMaps(&birth_map, &death_map, &parent_child_set); 152 data->SnapshotMaps(0, &birth_map, &deaths, &parent_child_set);
151 EXPECT_EQ(0u, birth_map.size()); 153 EXPECT_EQ(0u, birth_map.size());
152 EXPECT_EQ(0u, death_map.size()); 154 EXPECT_EQ(0u, deaths.size());
153 EXPECT_EQ(0u, parent_child_set.size()); 155 EXPECT_EQ(0u, parent_child_set.size());
154 156
155 // Clean up with no leaking. 157 // Clean up with no leaking.
156 Reset(); 158 Reset();
157 159
158 // Do it again, just to be sure we reset state completely. 160 // Do it again, just to be sure we reset state completely.
159 EXPECT_TRUE(ThreadData::InitializeAndSetTrackingStatus( 161 EXPECT_TRUE(ThreadData::InitializeAndSetTrackingStatus(
160 ThreadData::PROFILING_CHILDREN_ACTIVE)); 162 ThreadData::PROFILING_CHILDREN_ACTIVE));
161 EXPECT_FALSE(ThreadData::first()); // No activity even on this thread. 163 EXPECT_FALSE(ThreadData::first()); // No activity even on this thread.
162 data = ThreadData::Get(); 164 data = ThreadData::Get();
163 EXPECT_TRUE(ThreadData::first()); // Now class was constructed. 165 EXPECT_TRUE(ThreadData::first()); // Now class was constructed.
164 ASSERT_TRUE(data); 166 ASSERT_TRUE(data);
165 EXPECT_FALSE(data->next()); 167 EXPECT_FALSE(data->next());
166 EXPECT_EQ(data, ThreadData::Get()); 168 EXPECT_EQ(data, ThreadData::Get());
167 birth_map.clear(); 169 birth_map.clear();
168 death_map.clear(); 170 deaths.clear();
169 parent_child_set.clear(); 171 parent_child_set.clear();
170 data->SnapshotMaps(&birth_map, &death_map, &parent_child_set); 172 data->SnapshotMaps(0, &birth_map, &deaths, &parent_child_set);
171 EXPECT_EQ(0u, birth_map.size()); 173 EXPECT_EQ(0u, birth_map.size());
172 EXPECT_EQ(0u, death_map.size()); 174 EXPECT_EQ(0u, deaths.size());
173 EXPECT_EQ(0u, parent_child_set.size()); 175 EXPECT_EQ(0u, parent_child_set.size());
174 } 176 }
175 177
176 TEST_F(TrackedObjectsTest, TinyStartupShutdown) { 178 TEST_F(TrackedObjectsTest, TinyStartupShutdown) {
177 if (!ThreadData::InitializeAndSetTrackingStatus( 179 if (!ThreadData::InitializeAndSetTrackingStatus(
178 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 180 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
181 // Don't run the test if task tracking is not compiled in.
179 return; 182 return;
180 } 183 }
181 184
182 // Instigate tracking on a single tracked object, on our thread. 185 // Instigate tracking on a single tracked object, on our thread.
183 const char kFunction[] = "TinyStartupShutdown"; 186 const char kFunction[] = "TinyStartupShutdown";
184 Location location(kFunction, kFile, kLineNumber, NULL); 187 Location location(kFunction, kFile, kLineNumber, NULL);
185 Births* first_birth = ThreadData::TallyABirthIfActive(location); 188 Births* first_birth = ThreadData::TallyABirthIfActive(location);
186 189
187 ThreadData* data = ThreadData::first(); 190 ThreadData* data = ThreadData::first();
188 ASSERT_TRUE(data); 191 ASSERT_TRUE(data);
189 EXPECT_FALSE(data->next()); 192 EXPECT_FALSE(data->next());
190 EXPECT_EQ(data, ThreadData::Get()); 193 EXPECT_EQ(data, ThreadData::Get());
191 ThreadData::BirthMap birth_map; 194 ThreadData::BirthMap birth_map;
192 ThreadData::DeathMap death_map; 195 ThreadData::DeathsSnapshot deaths;
193 ThreadData::ParentChildSet parent_child_set; 196 ThreadData::ParentChildSet parent_child_set;
194 data->SnapshotMaps(&birth_map, &death_map, &parent_child_set); 197 data->SnapshotMaps(0, &birth_map, &deaths, &parent_child_set);
195 EXPECT_EQ(1u, birth_map.size()); // 1 birth location. 198 EXPECT_EQ(1u, birth_map.size()); // 1 birth location.
196 EXPECT_EQ(1, birth_map.begin()->second->birth_count()); // 1 birth. 199 EXPECT_EQ(1, birth_map.begin()->second->birth_count()); // 1 birth.
197 EXPECT_EQ(0u, death_map.size()); // No deaths. 200 EXPECT_EQ(0u, deaths.size()); // No deaths.
198 EXPECT_EQ(0u, parent_child_set.size()); // No children. 201 EXPECT_EQ(0u, parent_child_set.size()); // No children.
199 202
200 203
201 // Now instigate another birth, while we are timing the run of the first 204 // Now instigate another birth, while we are timing the run of the first
202 // execution. 205 // execution.
203 ThreadData::PrepareForStartOfRun(first_birth); 206 ThreadData::PrepareForStartOfRun(first_birth);
204 // Create a child (using the same birth location). 207 // Create a child (using the same birth location).
205 // TrackingInfo will call TallyABirth() during construction. 208 // TrackingInfo will call TallyABirth() during construction.
206 const int32 start_time = 1; 209 const int32 start_time = 1;
207 base::TimeTicks kBogusBirthTime = base::TimeTicks() + 210 base::TimeTicks kBogusBirthTime = base::TimeTicks() +
208 base::TimeDelta::FromMilliseconds(start_time); 211 base::TimeDelta::FromMilliseconds(start_time);
209 base::TrackingInfo pending_task(location, kBogusBirthTime); 212 base::TrackingInfo pending_task(location, kBogusBirthTime);
210 SetTestTime(1); 213 SetTestTime(1);
211 TaskStopwatch stopwatch; 214 TaskStopwatch stopwatch;
212 stopwatch.Start(); 215 stopwatch.Start();
213 // Finally conclude the outer run. 216 // Finally conclude the outer run.
214 const int32 time_elapsed = 1000; 217 const int32 time_elapsed = 1000;
215 SetTestTime(start_time + time_elapsed); 218 SetTestTime(start_time + time_elapsed);
216 stopwatch.Stop(); 219 stopwatch.Stop();
217 220
218 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 221 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
219 222
220 birth_map.clear(); 223 birth_map.clear();
221 death_map.clear(); 224 deaths.clear();
222 parent_child_set.clear(); 225 parent_child_set.clear();
223 data->SnapshotMaps(&birth_map, &death_map, &parent_child_set); 226 data->SnapshotMaps(0, &birth_map, &deaths, &parent_child_set);
224 EXPECT_EQ(1u, birth_map.size()); // 1 birth location. 227 EXPECT_EQ(1u, birth_map.size()); // 1 birth location.
225 EXPECT_EQ(2, birth_map.begin()->second->birth_count()); // 2 births. 228 EXPECT_EQ(2, birth_map.begin()->second->birth_count()); // 2 births.
226 EXPECT_EQ(1u, death_map.size()); // 1 location. 229 EXPECT_EQ(1u, deaths.size()); // 1 location.
227 EXPECT_EQ(1, death_map.begin()->second.count()); // 1 death. 230 EXPECT_EQ(1, deaths.begin()->second.death_data.count); // 1 death.
228 if (ThreadData::TrackingParentChildStatus()) { 231 if (ThreadData::TrackingParentChildStatus()) {
229 EXPECT_EQ(1u, parent_child_set.size()); // 1 child. 232 EXPECT_EQ(1u, parent_child_set.size()); // 1 child.
230 EXPECT_EQ(parent_child_set.begin()->first, 233 EXPECT_EQ(parent_child_set.begin()->first,
231 parent_child_set.begin()->second); 234 parent_child_set.begin()->second);
232 } else { 235 } else {
233 EXPECT_EQ(0u, parent_child_set.size()); // no stats. 236 EXPECT_EQ(0u, parent_child_set.size()); // no stats.
234 } 237 }
235 238
236 // The births were at the same location as the one known death. 239 // The births were at the same location as the one known death.
237 EXPECT_EQ(birth_map.begin()->second, death_map.begin()->first); 240 EXPECT_EQ(birth_map.begin()->second, deaths.begin()->first);
238 241
239 ProcessDataSnapshot process_data; 242 ProcessDataSnapshot process_data;
240 ThreadData::Snapshot(&process_data); 243 ThreadData::Snapshot(0, &process_data);
241 244
242 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 245 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
243 auto it = process_data.phased_process_data_snapshots.find(0); 246 auto it = process_data.phased_process_data_snapshots.find(0);
244 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end()); 247 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
245 const ProcessDataPhaseSnapshot& process_data_phase = it->second; 248 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
246 ASSERT_EQ(1u, process_data_phase.tasks.size()); 249 ASSERT_EQ(1u, process_data_phase.tasks.size());
247 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name); 250 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name);
248 EXPECT_EQ(kFunction, 251 EXPECT_EQ(kFunction,
249 process_data_phase.tasks[0].birth.location.function_name); 252 process_data_phase.tasks[0].birth.location.function_name);
250 EXPECT_EQ(kLineNumber, 253 EXPECT_EQ(kLineNumber,
(...skipping 30 matching lines...) Expand all
281 EXPECT_EQ(kWorkerThreadName, 284 EXPECT_EQ(kWorkerThreadName,
282 process_data_phase.descendants[0].child.thread_name); 285 process_data_phase.descendants[0].child.thread_name);
283 } else { 286 } else {
284 EXPECT_EQ(0u, process_data_phase.descendants.size()); 287 EXPECT_EQ(0u, process_data_phase.descendants.size());
285 } 288 }
286 } 289 }
287 290
288 TEST_F(TrackedObjectsTest, DeathDataTest) { 291 TEST_F(TrackedObjectsTest, DeathDataTest) {
289 if (!ThreadData::InitializeAndSetTrackingStatus( 292 if (!ThreadData::InitializeAndSetTrackingStatus(
290 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 293 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
294 // Don't run the test if task tracking is not compiled in.
291 return; 295 return;
292 } 296 }
293 297
294 scoped_ptr<DeathData> data(new DeathData()); 298 scoped_ptr<DeathData> data(new DeathData());
295 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL)); 299 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL));
296 EXPECT_EQ(data->run_duration_sum(), 0); 300 EXPECT_EQ(data->run_duration_sum(), 0);
301 EXPECT_EQ(data->run_duration_max(), 0);
297 EXPECT_EQ(data->run_duration_sample(), 0); 302 EXPECT_EQ(data->run_duration_sample(), 0);
298 EXPECT_EQ(data->queue_duration_sum(), 0); 303 EXPECT_EQ(data->queue_duration_sum(), 0);
304 EXPECT_EQ(data->queue_duration_max(), 0);
299 EXPECT_EQ(data->queue_duration_sample(), 0); 305 EXPECT_EQ(data->queue_duration_sample(), 0);
300 EXPECT_EQ(data->count(), 0); 306 EXPECT_EQ(data->count(), 0);
307 EXPECT_EQ(nullptr, data->last_phase_snapshot());
301 308
302 int32 run_ms = 42; 309 int32 run_ms = 42;
303 int32 queue_ms = 8; 310 int32 queue_ms = 8;
304 311
305 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. 312 const int kUnrandomInt = 0; // Fake random int that ensure we sample data.
306 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); 313 data->RecordDeath(queue_ms, run_ms, kUnrandomInt);
307 EXPECT_EQ(data->run_duration_sum(), run_ms); 314 EXPECT_EQ(data->run_duration_sum(), run_ms);
315 EXPECT_EQ(data->run_duration_max(), run_ms);
308 EXPECT_EQ(data->run_duration_sample(), run_ms); 316 EXPECT_EQ(data->run_duration_sample(), run_ms);
309 EXPECT_EQ(data->queue_duration_sum(), queue_ms); 317 EXPECT_EQ(data->queue_duration_sum(), queue_ms);
318 EXPECT_EQ(data->queue_duration_max(), queue_ms);
310 EXPECT_EQ(data->queue_duration_sample(), queue_ms); 319 EXPECT_EQ(data->queue_duration_sample(), queue_ms);
311 EXPECT_EQ(data->count(), 1); 320 EXPECT_EQ(data->count(), 1);
321 EXPECT_EQ(nullptr, data->last_phase_snapshot());
312 322
313 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); 323 data->RecordDeath(queue_ms, run_ms, kUnrandomInt);
314 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms); 324 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms);
325 EXPECT_EQ(data->run_duration_max(), run_ms);
315 EXPECT_EQ(data->run_duration_sample(), run_ms); 326 EXPECT_EQ(data->run_duration_sample(), run_ms);
316 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms); 327 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms);
328 EXPECT_EQ(data->queue_duration_max(), queue_ms);
317 EXPECT_EQ(data->queue_duration_sample(), queue_ms); 329 EXPECT_EQ(data->queue_duration_sample(), queue_ms);
318 EXPECT_EQ(data->count(), 2); 330 EXPECT_EQ(data->count(), 2);
331 EXPECT_EQ(nullptr, data->last_phase_snapshot());
319 332
320 DeathDataSnapshot snapshot(*data); 333 DeathDataSnapshot snapshot(*data);
321 EXPECT_EQ(2, snapshot.count); 334 EXPECT_EQ(2, snapshot.count);
322 EXPECT_EQ(2 * run_ms, snapshot.run_duration_sum); 335 EXPECT_EQ(2 * run_ms, snapshot.run_duration_sum);
323 EXPECT_EQ(run_ms, snapshot.run_duration_max); 336 EXPECT_EQ(run_ms, snapshot.run_duration_max);
324 EXPECT_EQ(run_ms, snapshot.run_duration_sample); 337 EXPECT_EQ(run_ms, snapshot.run_duration_sample);
325 EXPECT_EQ(2 * queue_ms, snapshot.queue_duration_sum); 338 EXPECT_EQ(2 * queue_ms, snapshot.queue_duration_sum);
326 EXPECT_EQ(queue_ms, snapshot.queue_duration_max); 339 EXPECT_EQ(queue_ms, snapshot.queue_duration_max);
327 EXPECT_EQ(queue_ms, snapshot.queue_duration_sample); 340 EXPECT_EQ(queue_ms, snapshot.queue_duration_sample);
341
342 data->OnProfilingPhaseCompleted(123);
343 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms);
344 EXPECT_EQ(data->run_duration_max(), 0);
345 EXPECT_EQ(data->run_duration_sample(), run_ms);
346 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms);
347 EXPECT_EQ(data->queue_duration_max(), 0);
348 EXPECT_EQ(data->queue_duration_sample(), queue_ms);
349 EXPECT_EQ(data->count(), 2);
350 ASSERT_NE(nullptr, data->last_phase_snapshot());
351 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase);
352 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count);
353 EXPECT_EQ(2 * run_ms,
354 data->last_phase_snapshot()->death_data.run_duration_sum);
355 EXPECT_EQ(run_ms, data->last_phase_snapshot()->death_data.run_duration_max);
356 EXPECT_EQ(run_ms,
357 data->last_phase_snapshot()->death_data.run_duration_sample);
358 EXPECT_EQ(2 * queue_ms,
359 data->last_phase_snapshot()->death_data.queue_duration_sum);
360 EXPECT_EQ(queue_ms,
361 data->last_phase_snapshot()->death_data.queue_duration_max);
362 EXPECT_EQ(queue_ms,
363 data->last_phase_snapshot()->death_data.queue_duration_sample);
364 EXPECT_EQ(nullptr, data->last_phase_snapshot()->prev);
365
366 int32 run_ms1 = 21;
367 int32 queue_ms1 = 4;
368
369 data->RecordDeath(queue_ms1, run_ms1, kUnrandomInt);
370 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms + run_ms1);
371 EXPECT_EQ(data->run_duration_max(), run_ms1);
372 EXPECT_EQ(data->run_duration_sample(), run_ms1);
373 EXPECT_EQ(data->queue_duration_sum(), queue_ms + queue_ms + queue_ms1);
374 EXPECT_EQ(data->queue_duration_max(), queue_ms1);
375 EXPECT_EQ(data->queue_duration_sample(), queue_ms1);
376 EXPECT_EQ(data->count(), 3);
377 ASSERT_NE(nullptr, data->last_phase_snapshot());
378 EXPECT_EQ(123, data->last_phase_snapshot()->profiling_phase);
379 EXPECT_EQ(2, data->last_phase_snapshot()->death_data.count);
380 EXPECT_EQ(2 * run_ms,
381 data->last_phase_snapshot()->death_data.run_duration_sum);
382 EXPECT_EQ(run_ms, data->last_phase_snapshot()->death_data.run_duration_max);
383 EXPECT_EQ(run_ms,
384 data->last_phase_snapshot()->death_data.run_duration_sample);
385 EXPECT_EQ(2 * queue_ms,
386 data->last_phase_snapshot()->death_data.queue_duration_sum);
387 EXPECT_EQ(queue_ms,
388 data->last_phase_snapshot()->death_data.queue_duration_max);
389 EXPECT_EQ(queue_ms,
390 data->last_phase_snapshot()->death_data.queue_duration_sample);
391 EXPECT_EQ(nullptr, data->last_phase_snapshot()->prev);
392 }
393
394 TEST_F(TrackedObjectsTest, CalculateDelta) {
395 if (!ThreadData::InitializeAndSetTrackingStatus(
396 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
397 // Don't run the test if task tracking is not compiled in.
398 return;
399 }
400
401 DeathDataSnapshot snapshot;
402 snapshot.count = 10;
403 snapshot.run_duration_sum = 100;
404 snapshot.run_duration_max = 50;
405 snapshot.run_duration_sample = 25;
406 snapshot.queue_duration_sum = 200;
407 snapshot.queue_duration_max = 101;
408 snapshot.queue_duration_sample = 26;
409
410 DeathDataSnapshot older_snapshot;
411 older_snapshot.count = 2;
412 older_snapshot.run_duration_sum = 95;
413 older_snapshot.run_duration_max = 48;
414 older_snapshot.run_duration_sample = 22;
415 older_snapshot.queue_duration_sum = 190;
416 older_snapshot.queue_duration_max = 99;
417 older_snapshot.queue_duration_sample = 21;
418
419 snapshot.CalculateDelta(older_snapshot);
420 EXPECT_EQ(8, snapshot.count);
421 EXPECT_EQ(5, snapshot.run_duration_sum);
422 EXPECT_EQ(50, snapshot.run_duration_max);
423 EXPECT_EQ(25, snapshot.run_duration_sample);
424 EXPECT_EQ(10, snapshot.queue_duration_sum);
425 EXPECT_EQ(101, snapshot.queue_duration_max);
426 EXPECT_EQ(26, snapshot.queue_duration_sample);
328 } 427 }
329 428
330 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotWorkerThread) { 429 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotWorkerThread) {
331 // Start in the deactivated state. 430 // Start in the deactivated state.
332 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) { 431 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) {
432 // Don't run the test if task tracking is not compiled in.
333 return; 433 return;
334 } 434 }
335 435
336 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread"; 436 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread";
337 Location location(kFunction, kFile, kLineNumber, NULL); 437 Location location(kFunction, kFile, kLineNumber, NULL);
338 TallyABirth(location, std::string()); 438 TallyABirth(location, std::string());
339 439
340 ProcessDataSnapshot process_data; 440 ProcessDataSnapshot process_data;
341 ThreadData::Snapshot(&process_data); 441 ThreadData::Snapshot(0, &process_data);
342 442
343 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 443 ASSERT_EQ(0u, 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 444
348 EXPECT_EQ(0u, process_data_phase.tasks.size());
349 EXPECT_EQ(0u, process_data_phase.descendants.size());
350 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 445 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
351 } 446 }
352 447
353 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) { 448 TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) {
354 // Start in the deactivated state. 449 // Start in the deactivated state.
355 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) { 450 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) {
451 // Don't run the test if task tracking is not compiled in.
356 return; 452 return;
357 } 453 }
358 454
359 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread"; 455 const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread";
360 Location location(kFunction, kFile, kLineNumber, NULL); 456 Location location(kFunction, kFile, kLineNumber, NULL);
361 TallyABirth(location, kMainThreadName); 457 TallyABirth(location, kMainThreadName);
362 458
363 ProcessDataSnapshot process_data; 459 ProcessDataSnapshot process_data;
364 ThreadData::Snapshot(&process_data); 460 ThreadData::Snapshot(0, &process_data);
365 461
366 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 462 ASSERT_EQ(0u, 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 463
371 EXPECT_EQ(0u, process_data_phase.tasks.size());
372 EXPECT_EQ(0u, process_data_phase.descendants.size());
373 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 464 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
374 } 465 }
375 466
376 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) { 467 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) {
377 if (!ThreadData::InitializeAndSetTrackingStatus( 468 if (!ThreadData::InitializeAndSetTrackingStatus(
378 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 469 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
470 // Don't run the test if task tracking is not compiled in.
379 return; 471 return;
380 } 472 }
381 473
382 const char kFunction[] = "BirthOnlyToSnapshotWorkerThread"; 474 const char kFunction[] = "BirthOnlyToSnapshotWorkerThread";
383 Location location(kFunction, kFile, kLineNumber, NULL); 475 Location location(kFunction, kFile, kLineNumber, NULL);
384 TallyABirth(location, std::string()); 476 TallyABirth(location, std::string());
385 477
386 ProcessDataSnapshot process_data; 478 ProcessDataSnapshot process_data;
387 ThreadData::Snapshot(&process_data); 479 ThreadData::Snapshot(0, &process_data);
388 ExpectSimpleProcessData(process_data, kFunction, kWorkerThreadName, 480 ExpectSimpleProcessData(process_data, kFunction, kWorkerThreadName,
389 kStillAlive, 1, 0, 0); 481 kStillAlive, 1, 0, 0);
390 } 482 }
391 483
392 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotMainThread) { 484 TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotMainThread) {
393 if (!ThreadData::InitializeAndSetTrackingStatus( 485 if (!ThreadData::InitializeAndSetTrackingStatus(
394 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 486 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
487 // Don't run the test if task tracking is not compiled in.
395 return; 488 return;
396 } 489 }
397 490
398 const char kFunction[] = "BirthOnlyToSnapshotMainThread"; 491 const char kFunction[] = "BirthOnlyToSnapshotMainThread";
399 Location location(kFunction, kFile, kLineNumber, NULL); 492 Location location(kFunction, kFile, kLineNumber, NULL);
400 TallyABirth(location, kMainThreadName); 493 TallyABirth(location, kMainThreadName);
401 494
402 ProcessDataSnapshot process_data; 495 ProcessDataSnapshot process_data;
403 ThreadData::Snapshot(&process_data); 496 ThreadData::Snapshot(0, &process_data);
404 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, kStillAlive, 497 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, kStillAlive,
405 1, 0, 0); 498 1, 0, 0);
406 } 499 }
407 500
408 TEST_F(TrackedObjectsTest, LifeCycleToSnapshotMainThread) { 501 TEST_F(TrackedObjectsTest, LifeCycleToSnapshotMainThread) {
409 if (!ThreadData::InitializeAndSetTrackingStatus( 502 if (!ThreadData::InitializeAndSetTrackingStatus(
410 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 503 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
504 // Don't run the test if task tracking is not compiled in.
411 return; 505 return;
412 } 506 }
413 507
414 const char kFunction[] = "LifeCycleToSnapshotMainThread"; 508 const char kFunction[] = "LifeCycleToSnapshotMainThread";
415 Location location(kFunction, kFile, kLineNumber, NULL); 509 Location location(kFunction, kFile, kLineNumber, NULL);
416 TallyABirth(location, kMainThreadName); 510 TallyABirth(location, kMainThreadName);
417 511
418 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 512 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
419 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 513 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
420 // TrackingInfo will call TallyABirth() during construction. 514 // TrackingInfo will call TallyABirth() during construction.
421 base::TrackingInfo pending_task(location, kDelayedStartTime); 515 base::TrackingInfo pending_task(location, kDelayedStartTime);
422 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 516 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
423 517
424 const unsigned int kStartOfRun = 5; 518 const unsigned int kStartOfRun = 5;
425 const unsigned int kEndOfRun = 7; 519 const unsigned int kEndOfRun = 7;
426 SetTestTime(kStartOfRun); 520 SetTestTime(kStartOfRun);
427 TaskStopwatch stopwatch; 521 TaskStopwatch stopwatch;
428 stopwatch.Start(); 522 stopwatch.Start();
429 SetTestTime(kEndOfRun); 523 SetTestTime(kEndOfRun);
430 stopwatch.Stop(); 524 stopwatch.Stop();
431 525
432 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 526 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
433 527
434 ProcessDataSnapshot process_data; 528 ProcessDataSnapshot process_data;
435 ThreadData::Snapshot(&process_data); 529 ThreadData::Snapshot(0, &process_data);
436 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, 530 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName,
437 kMainThreadName, 1, 2, 4); 531 kMainThreadName, 1, 2, 4);
438 } 532 }
439 533
534 TEST_F(TrackedObjectsTest, TwoPhases) {
535 if (!ThreadData::InitializeAndSetTrackingStatus(
536 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
537 // Don't run the test if task tracking is not compiled in.
538 return;
539 }
540
541 const char kFunction[] = "TwoPhases";
542 Location location(kFunction, kFile, kLineNumber, NULL);
543 TallyABirth(location, kMainThreadName);
544
545 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
546 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
547 // TrackingInfo will call TallyABirth() during construction.
548 base::TrackingInfo pending_task(location, kDelayedStartTime);
549 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
550
551 const unsigned int kStartOfRun = 5;
552 const unsigned int kEndOfRun = 7;
553 SetTestTime(kStartOfRun);
554 TaskStopwatch stopwatch;
555 stopwatch.Start();
556 SetTestTime(kEndOfRun);
557 stopwatch.Stop();
558
559 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
560
561 ThreadData::OnProfilingPhaseCompleted(0);
562
563 TallyABirth(location, kMainThreadName);
564
565 const TrackedTime kTimePosted1 = TrackedTime::FromMilliseconds(9);
566 const base::TimeTicks kDelayedStartTime1 = base::TimeTicks();
567 // TrackingInfo will call TallyABirth() during construction.
568 base::TrackingInfo pending_task1(location, kDelayedStartTime1);
569 pending_task1.time_posted = kTimePosted1; // Overwrite implied Now().
570
571 const unsigned int kStartOfRun1 = 11;
572 const unsigned int kEndOfRun1 = 21;
573 SetTestTime(kStartOfRun1);
574 TaskStopwatch stopwatch1;
575 stopwatch1.Start();
576 SetTestTime(kEndOfRun1);
577 stopwatch1.Stop();
578
579 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task1, stopwatch1);
580
581 ProcessDataSnapshot process_data;
582 ThreadData::Snapshot(1, &process_data);
583
584 ASSERT_EQ(2u, process_data.phased_process_data_snapshots.size());
585
586 auto it0 = process_data.phased_process_data_snapshots.find(0);
587 ASSERT_TRUE(it0 != process_data.phased_process_data_snapshots.end());
588 const ProcessDataPhaseSnapshot& process_data_phase0 = it0->second;
589
590 ASSERT_EQ(1u, process_data_phase0.tasks.size());
591
592 EXPECT_EQ(kFile, process_data_phase0.tasks[0].birth.location.file_name);
593 EXPECT_EQ(kFunction,
594 process_data_phase0.tasks[0].birth.location.function_name);
595 EXPECT_EQ(kLineNumber,
596 process_data_phase0.tasks[0].birth.location.line_number);
597
598 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].birth.thread_name);
599
600 EXPECT_EQ(1, process_data_phase0.tasks[0].death_data.count);
601 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_sum);
602 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_max);
603 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_sample);
604 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_sum);
605 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_max);
606 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_sample);
607
608 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].death_thread_name);
609
610 EXPECT_EQ(0u, process_data_phase0.descendants.size());
611
612 auto it1 = process_data.phased_process_data_snapshots.find(1);
613 ASSERT_TRUE(it1 != process_data.phased_process_data_snapshots.end());
614 const ProcessDataPhaseSnapshot& process_data_phase1 = it1->second;
615
616 ASSERT_EQ(1u, process_data_phase1.tasks.size());
617
618 EXPECT_EQ(kFile, process_data_phase1.tasks[0].birth.location.file_name);
619 EXPECT_EQ(kFunction,
620 process_data_phase1.tasks[0].birth.location.function_name);
621 EXPECT_EQ(kLineNumber,
622 process_data_phase1.tasks[0].birth.location.line_number);
623
624 EXPECT_EQ(kMainThreadName, process_data_phase1.tasks[0].birth.thread_name);
625
626 EXPECT_EQ(1, process_data_phase1.tasks[0].death_data.count);
627 EXPECT_EQ(10, process_data_phase1.tasks[0].death_data.run_duration_sum);
628 EXPECT_EQ(10, process_data_phase1.tasks[0].death_data.run_duration_max);
629 EXPECT_EQ(10, process_data_phase1.tasks[0].death_data.run_duration_sample);
630 EXPECT_EQ(2, process_data_phase1.tasks[0].death_data.queue_duration_sum);
631 EXPECT_EQ(2, process_data_phase1.tasks[0].death_data.queue_duration_max);
632 EXPECT_EQ(2, process_data_phase1.tasks[0].death_data.queue_duration_sample);
633
634 EXPECT_EQ(kMainThreadName, process_data_phase1.tasks[0].death_thread_name);
635
636 EXPECT_EQ(0u, process_data_phase1.descendants.size());
637
638 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
639 }
640
641 TEST_F(TrackedObjectsTest, ThreePhases) {
642 if (!ThreadData::InitializeAndSetTrackingStatus(
643 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
644 // Don't run the test if task tracking is not compiled in.
645 return;
646 }
647
648 const char kFunction[] = "ThreePhases";
649 Location location(kFunction, kFile, kLineNumber, NULL);
650
651 // Phase 0
652 {
653 TallyABirth(location, kMainThreadName);
654
655 // TrackingInfo will call TallyABirth() during construction.
656 SetTestTime(10);
657 base::TrackingInfo pending_task(location, base::TimeTicks());
658
659 SetTestTime(17);
660 TaskStopwatch stopwatch;
661 stopwatch.Start();
662 SetTestTime(23);
663 stopwatch.Stop();
664
665 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
666 }
667
668 ThreadData::OnProfilingPhaseCompleted(0);
669
670 // Phase 1
671 {
672 TallyABirth(location, kMainThreadName);
673
674 SetTestTime(30);
675 base::TrackingInfo pending_task(location, base::TimeTicks());
676
677 SetTestTime(35);
678 TaskStopwatch stopwatch;
679 stopwatch.Start();
680 SetTestTime(39);
681 stopwatch.Stop();
682
683 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
684 }
685
686 ThreadData::OnProfilingPhaseCompleted(1);
687
688 // Phase 2
689 {
690 TallyABirth(location, kMainThreadName);
691
692 // TrackingInfo will call TallyABirth() during construction.
693 SetTestTime(40);
694 base::TrackingInfo pending_task(location, base::TimeTicks());
695
696 SetTestTime(43);
697 TaskStopwatch stopwatch;
698 stopwatch.Start();
699 SetTestTime(45);
700 stopwatch.Stop();
701
702 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
703 }
704
705 // Snapshot and check results.
706 ProcessDataSnapshot process_data;
707 ThreadData::Snapshot(2, &process_data);
708
709 ASSERT_EQ(3u, process_data.phased_process_data_snapshots.size());
710
711 auto it0 = process_data.phased_process_data_snapshots.find(0);
712 ASSERT_TRUE(it0 != process_data.phased_process_data_snapshots.end());
713 const ProcessDataPhaseSnapshot& process_data_phase0 = it0->second;
714
715 ASSERT_EQ(1u, process_data_phase0.tasks.size());
716
717 EXPECT_EQ(kFile, process_data_phase0.tasks[0].birth.location.file_name);
718 EXPECT_EQ(kFunction,
719 process_data_phase0.tasks[0].birth.location.function_name);
720 EXPECT_EQ(kLineNumber,
721 process_data_phase0.tasks[0].birth.location.line_number);
722
723 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].birth.thread_name);
724
725 EXPECT_EQ(1, process_data_phase0.tasks[0].death_data.count);
726 EXPECT_EQ(6, process_data_phase0.tasks[0].death_data.run_duration_sum);
727 EXPECT_EQ(6, process_data_phase0.tasks[0].death_data.run_duration_max);
728 EXPECT_EQ(6, process_data_phase0.tasks[0].death_data.run_duration_sample);
729 EXPECT_EQ(7, process_data_phase0.tasks[0].death_data.queue_duration_sum);
730 EXPECT_EQ(7, process_data_phase0.tasks[0].death_data.queue_duration_max);
731 EXPECT_EQ(7, process_data_phase0.tasks[0].death_data.queue_duration_sample);
732
733 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].death_thread_name);
734
735 EXPECT_EQ(0u, process_data_phase0.descendants.size());
736
737 auto it1 = process_data.phased_process_data_snapshots.find(1);
738 ASSERT_TRUE(it1 != process_data.phased_process_data_snapshots.end());
739 const ProcessDataPhaseSnapshot& process_data_phase1 = it1->second;
740
741 ASSERT_EQ(1u, process_data_phase1.tasks.size());
742
743 EXPECT_EQ(kFile, process_data_phase1.tasks[0].birth.location.file_name);
744 EXPECT_EQ(kFunction,
745 process_data_phase1.tasks[0].birth.location.function_name);
746 EXPECT_EQ(kLineNumber,
747 process_data_phase1.tasks[0].birth.location.line_number);
748
749 EXPECT_EQ(kMainThreadName, process_data_phase1.tasks[0].birth.thread_name);
750
751 EXPECT_EQ(1, process_data_phase1.tasks[0].death_data.count);
752 EXPECT_EQ(4, process_data_phase1.tasks[0].death_data.run_duration_sum);
753 EXPECT_EQ(4, process_data_phase1.tasks[0].death_data.run_duration_max);
754 EXPECT_EQ(4, process_data_phase1.tasks[0].death_data.run_duration_sample);
755 EXPECT_EQ(5, process_data_phase1.tasks[0].death_data.queue_duration_sum);
756 EXPECT_EQ(5, process_data_phase1.tasks[0].death_data.queue_duration_max);
757 EXPECT_EQ(5, process_data_phase1.tasks[0].death_data.queue_duration_sample);
758
759 EXPECT_EQ(kMainThreadName, process_data_phase1.tasks[0].death_thread_name);
760
761 EXPECT_EQ(0u, process_data_phase1.descendants.size());
762
763 auto it2 = process_data.phased_process_data_snapshots.find(2);
764 ASSERT_TRUE(it2 != process_data.phased_process_data_snapshots.end());
765 const ProcessDataPhaseSnapshot& process_data_phase2 = it2->second;
766
767 ASSERT_EQ(1u, process_data_phase2.tasks.size());
768
769 EXPECT_EQ(kFile, process_data_phase2.tasks[0].birth.location.file_name);
770 EXPECT_EQ(kFunction,
771 process_data_phase2.tasks[0].birth.location.function_name);
772 EXPECT_EQ(kLineNumber,
773 process_data_phase2.tasks[0].birth.location.line_number);
774
775 EXPECT_EQ(kMainThreadName, process_data_phase2.tasks[0].birth.thread_name);
776
777 EXPECT_EQ(1, process_data_phase2.tasks[0].death_data.count);
778 EXPECT_EQ(2, process_data_phase2.tasks[0].death_data.run_duration_sum);
779 EXPECT_EQ(2, process_data_phase2.tasks[0].death_data.run_duration_max);
780 EXPECT_EQ(2, process_data_phase2.tasks[0].death_data.run_duration_sample);
781 EXPECT_EQ(3, process_data_phase2.tasks[0].death_data.queue_duration_sum);
782 EXPECT_EQ(3, process_data_phase2.tasks[0].death_data.queue_duration_max);
783 EXPECT_EQ(3, process_data_phase2.tasks[0].death_data.queue_duration_sample);
784
785 EXPECT_EQ(kMainThreadName, process_data_phase2.tasks[0].death_thread_name);
786
787 EXPECT_EQ(0u, process_data_phase2.descendants.size());
788
789 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
790 }
791
792 TEST_F(TrackedObjectsTest, TwoPhasesSecondEmpty) {
793 if (!ThreadData::InitializeAndSetTrackingStatus(
794 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
795 // Don't run the test if task tracking is not compiled in.
796 return;
797 }
798
799 const char kFunction[] = "TwoPhasesSecondEmpty";
800 Location location(kFunction, kFile, kLineNumber, NULL);
801 ThreadData::InitializeThreadContext(kMainThreadName);
802
803 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
804 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
805 // TrackingInfo will call TallyABirth() during construction.
806 base::TrackingInfo pending_task(location, kDelayedStartTime);
807 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
808
809 const unsigned int kStartOfRun = 5;
810 const unsigned int kEndOfRun = 7;
811 SetTestTime(kStartOfRun);
812 TaskStopwatch stopwatch;
813 stopwatch.Start();
814 SetTestTime(kEndOfRun);
815 stopwatch.Stop();
816
817 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
818
819 ThreadData::OnProfilingPhaseCompleted(0);
820
821 ProcessDataSnapshot process_data;
822 ThreadData::Snapshot(1, &process_data);
823
824 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
825
826 auto it0 = process_data.phased_process_data_snapshots.find(0);
827 ASSERT_TRUE(it0 != process_data.phased_process_data_snapshots.end());
828 const ProcessDataPhaseSnapshot& process_data_phase0 = it0->second;
829
830 ASSERT_EQ(1u, process_data_phase0.tasks.size());
831
832 EXPECT_EQ(kFile, process_data_phase0.tasks[0].birth.location.file_name);
833 EXPECT_EQ(kFunction,
834 process_data_phase0.tasks[0].birth.location.function_name);
835 EXPECT_EQ(kLineNumber,
836 process_data_phase0.tasks[0].birth.location.line_number);
837
838 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].birth.thread_name);
839
840 EXPECT_EQ(1, process_data_phase0.tasks[0].death_data.count);
841 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_sum);
842 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_max);
843 EXPECT_EQ(2, process_data_phase0.tasks[0].death_data.run_duration_sample);
844 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_sum);
845 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_max);
846 EXPECT_EQ(4, process_data_phase0.tasks[0].death_data.queue_duration_sample);
847
848 EXPECT_EQ(kMainThreadName, process_data_phase0.tasks[0].death_thread_name);
849
850 EXPECT_EQ(0u, process_data_phase0.descendants.size());
851
852 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
853 }
854
440 // We will deactivate tracking after the birth, and before the death, and 855 // We will deactivate tracking after the birth, and before the death, and
441 // demonstrate that the lifecycle is completely tallied. This ensures that 856 // demonstrate that the lifecycle is completely tallied. This ensures that
442 // our tallied births are matched by tallied deaths (except for when the 857 // our tallied births are matched by tallied deaths (except for when the
443 // task is still running, or is queued). 858 // task is still running, or is queued).
444 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) { 859 TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToSnapshotMainThread) {
445 if (!ThreadData::InitializeAndSetTrackingStatus( 860 if (!ThreadData::InitializeAndSetTrackingStatus(
446 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 861 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
862 // Don't run the test if task tracking is not compiled in.
447 return; 863 return;
448 } 864 }
449 865
450 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread"; 866 const char kFunction[] = "LifeCycleMidDeactivatedToSnapshotMainThread";
451 Location location(kFunction, kFile, kLineNumber, NULL); 867 Location location(kFunction, kFile, kLineNumber, NULL);
452 TallyABirth(location, kMainThreadName); 868 TallyABirth(location, kMainThreadName);
453 869
454 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 870 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
455 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 871 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
456 // TrackingInfo will call TallyABirth() during construction. 872 // TrackingInfo will call TallyABirth() during construction.
457 base::TrackingInfo pending_task(location, kDelayedStartTime); 873 base::TrackingInfo pending_task(location, kDelayedStartTime);
458 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 874 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
459 875
460 // Turn off tracking now that we have births. 876 // Turn off tracking now that we have births.
461 EXPECT_TRUE( 877 EXPECT_TRUE(
462 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)); 878 ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED));
463 879
464 const unsigned int kStartOfRun = 5; 880 const unsigned int kStartOfRun = 5;
465 const unsigned int kEndOfRun = 7; 881 const unsigned int kEndOfRun = 7;
466 SetTestTime(kStartOfRun); 882 SetTestTime(kStartOfRun);
467 TaskStopwatch stopwatch; 883 TaskStopwatch stopwatch;
468 stopwatch.Start(); 884 stopwatch.Start();
469 SetTestTime(kEndOfRun); 885 SetTestTime(kEndOfRun);
470 stopwatch.Stop(); 886 stopwatch.Stop();
471 887
472 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 888 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
473 889
474 ProcessDataSnapshot process_data; 890 ProcessDataSnapshot process_data;
475 ThreadData::Snapshot(&process_data); 891 ThreadData::Snapshot(0, &process_data);
476 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, 892 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName,
477 kMainThreadName, 1, 2, 4); 893 kMainThreadName, 1, 2, 4);
478 } 894 }
479 895
480 // We will deactivate tracking before starting a life cycle, and neither 896 // We will deactivate tracking before starting a life cycle, and neither
481 // the birth nor the death will be recorded. 897 // the birth nor the death will be recorded.
482 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) { 898 TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToSnapshotMainThread) {
483 // Start in the deactivated state. 899 // Start in the deactivated state.
484 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) { 900 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) {
901 // Don't run the test if task tracking is not compiled in.
485 return; 902 return;
486 } 903 }
487 904
488 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread"; 905 const char kFunction[] = "LifeCyclePreDeactivatedToSnapshotMainThread";
489 Location location(kFunction, kFile, kLineNumber, NULL); 906 Location location(kFunction, kFile, kLineNumber, NULL);
490 TallyABirth(location, kMainThreadName); 907 TallyABirth(location, kMainThreadName);
491 908
492 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 909 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
493 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 910 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
494 // TrackingInfo will call TallyABirth() during construction. 911 // TrackingInfo will call TallyABirth() during construction.
495 base::TrackingInfo pending_task(location, kDelayedStartTime); 912 base::TrackingInfo pending_task(location, kDelayedStartTime);
496 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 913 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
497 914
498 const unsigned int kStartOfRun = 5; 915 const unsigned int kStartOfRun = 5;
499 const unsigned int kEndOfRun = 7; 916 const unsigned int kEndOfRun = 7;
500 SetTestTime(kStartOfRun); 917 SetTestTime(kStartOfRun);
501 TaskStopwatch stopwatch; 918 TaskStopwatch stopwatch;
502 stopwatch.Start(); 919 stopwatch.Start();
503 SetTestTime(kEndOfRun); 920 SetTestTime(kEndOfRun);
504 stopwatch.Stop(); 921 stopwatch.Stop();
505 922
506 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 923 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
507 924
508 ProcessDataSnapshot process_data; 925 ProcessDataSnapshot process_data;
509 ThreadData::Snapshot(&process_data); 926 ThreadData::Snapshot(0, &process_data);
510 927
511 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 928 ASSERT_EQ(0u, 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 929
516 EXPECT_EQ(0u, process_data_phase.tasks.size());
517 EXPECT_EQ(0u, process_data_phase.descendants.size());
518 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 930 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
519 } 931 }
520 932
521 TEST_F(TrackedObjectsTest, TwoLives) { 933 TEST_F(TrackedObjectsTest, TwoLives) {
522 if (!ThreadData::InitializeAndSetTrackingStatus( 934 if (!ThreadData::InitializeAndSetTrackingStatus(
523 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 935 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
936 // Don't run the test if task tracking is not compiled in.
524 return; 937 return;
525 } 938 }
526 939
527 const char kFunction[] = "TwoLives"; 940 const char kFunction[] = "TwoLives";
528 Location location(kFunction, kFile, kLineNumber, NULL); 941 Location location(kFunction, kFile, kLineNumber, NULL);
529 TallyABirth(location, kMainThreadName); 942 TallyABirth(location, kMainThreadName);
530 943
531 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 944 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
532 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 945 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
533 // TrackingInfo will call TallyABirth() during construction. 946 // TrackingInfo will call TallyABirth() during construction.
(...skipping 15 matching lines...) Expand all
549 pending_task2.time_posted = kTimePosted; // Overwrite implied Now(). 962 pending_task2.time_posted = kTimePosted; // Overwrite implied Now().
550 SetTestTime(kStartOfRun); 963 SetTestTime(kStartOfRun);
551 TaskStopwatch stopwatch2; 964 TaskStopwatch stopwatch2;
552 stopwatch2.Start(); 965 stopwatch2.Start();
553 SetTestTime(kEndOfRun); 966 SetTestTime(kEndOfRun);
554 stopwatch2.Stop(); 967 stopwatch2.Stop();
555 968
556 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task2, stopwatch2); 969 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task2, stopwatch2);
557 970
558 ProcessDataSnapshot process_data; 971 ProcessDataSnapshot process_data;
559 ThreadData::Snapshot(&process_data); 972 ThreadData::Snapshot(0, &process_data);
560 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, 973 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName,
561 kMainThreadName, 2, 2, 4); 974 kMainThreadName, 2, 2, 4);
562 } 975 }
563 976
564 TEST_F(TrackedObjectsTest, DifferentLives) { 977 TEST_F(TrackedObjectsTest, DifferentLives) {
565 if (!ThreadData::InitializeAndSetTrackingStatus( 978 if (!ThreadData::InitializeAndSetTrackingStatus(
566 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 979 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
980 // Don't run the test if task tracking is not compiled in.
567 return; 981 return;
568 } 982 }
569 983
570 // Use a well named thread. 984 // Use a well named thread.
571 ThreadData::InitializeThreadContext(kMainThreadName); 985 ThreadData::InitializeThreadContext(kMainThreadName);
572 const char kFunction[] = "DifferentLives"; 986 const char kFunction[] = "DifferentLives";
573 Location location(kFunction, kFile, kLineNumber, NULL); 987 Location location(kFunction, kFile, kLineNumber, NULL);
574 988
575 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 989 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
576 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 990 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
(...skipping 12 matching lines...) Expand all
589 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch); 1003 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, stopwatch);
590 1004
591 const int kSecondFakeLineNumber = 999; 1005 const int kSecondFakeLineNumber = 999;
592 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL); 1006 Location second_location(kFunction, kFile, kSecondFakeLineNumber, NULL);
593 1007
594 // TrackingInfo will call TallyABirth() during construction. 1008 // TrackingInfo will call TallyABirth() during construction.
595 base::TrackingInfo pending_task2(second_location, kDelayedStartTime); 1009 base::TrackingInfo pending_task2(second_location, kDelayedStartTime);
596 pending_task2.time_posted = kTimePosted; // Overwrite implied Now(). 1010 pending_task2.time_posted = kTimePosted; // Overwrite implied Now().
597 1011
598 ProcessDataSnapshot process_data; 1012 ProcessDataSnapshot process_data;
599 ThreadData::Snapshot(&process_data); 1013 ThreadData::Snapshot(0, &process_data);
600 1014
601 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 1015 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
602 auto it = process_data.phased_process_data_snapshots.find(0); 1016 auto it = process_data.phased_process_data_snapshots.find(0);
603 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end()); 1017 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
604 const ProcessDataPhaseSnapshot& process_data_phase = it->second; 1018 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
605 1019
606 ASSERT_EQ(2u, process_data_phase.tasks.size()); 1020 ASSERT_EQ(2u, process_data_phase.tasks.size());
607 1021
608 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name); 1022 EXPECT_EQ(kFile, process_data_phase.tasks[0].birth.location.file_name);
609 EXPECT_EQ(kFunction, 1023 EXPECT_EQ(kFunction,
(...skipping 23 matching lines...) Expand all
633 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_max); 1047 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_max);
634 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_sample); 1048 EXPECT_EQ(0, process_data_phase.tasks[1].death_data.queue_duration_sample);
635 EXPECT_EQ(kStillAlive, process_data_phase.tasks[1].death_thread_name); 1049 EXPECT_EQ(kStillAlive, process_data_phase.tasks[1].death_thread_name);
636 EXPECT_EQ(0u, process_data_phase.descendants.size()); 1050 EXPECT_EQ(0u, process_data_phase.descendants.size());
637 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 1051 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
638 } 1052 }
639 1053
640 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) { 1054 TEST_F(TrackedObjectsTest, TaskWithNestedExclusion) {
641 if (!ThreadData::InitializeAndSetTrackingStatus( 1055 if (!ThreadData::InitializeAndSetTrackingStatus(
642 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 1056 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
1057 // Don't run the test if task tracking is not compiled in.
643 return; 1058 return;
644 } 1059 }
645 1060
646 const char kFunction[] = "TaskWithNestedExclusion"; 1061 const char kFunction[] = "TaskWithNestedExclusion";
647 Location location(kFunction, kFile, kLineNumber, NULL); 1062 Location location(kFunction, kFile, kLineNumber, NULL);
648 TallyABirth(location, kMainThreadName); 1063 TallyABirth(location, kMainThreadName);
649 1064
650 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1065 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
651 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1066 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
652 // TrackingInfo will call TallyABirth() during construction. 1067 // TrackingInfo will call TallyABirth() during construction.
653 base::TrackingInfo pending_task(location, kDelayedStartTime); 1068 base::TrackingInfo pending_task(location, kDelayedStartTime);
654 pending_task.time_posted = kTimePosted; // Overwrite implied Now(). 1069 pending_task.time_posted = kTimePosted; // Overwrite implied Now().
655 1070
656 SetTestTime(5); 1071 SetTestTime(5);
657 TaskStopwatch task_stopwatch; 1072 TaskStopwatch task_stopwatch;
658 task_stopwatch.Start(); 1073 task_stopwatch.Start();
659 { 1074 {
660 SetTestTime(8); 1075 SetTestTime(8);
661 TaskStopwatch exclusion_stopwatch; 1076 TaskStopwatch exclusion_stopwatch;
662 exclusion_stopwatch.Start(); 1077 exclusion_stopwatch.Start();
663 SetTestTime(12); 1078 SetTestTime(12);
664 exclusion_stopwatch.Stop(); 1079 exclusion_stopwatch.Stop();
665 } 1080 }
666 SetTestTime(15); 1081 SetTestTime(15);
667 task_stopwatch.Stop(); 1082 task_stopwatch.Stop();
668 1083
669 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch); 1084 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch);
670 1085
671 ProcessDataSnapshot process_data; 1086 ProcessDataSnapshot process_data;
672 ThreadData::Snapshot(&process_data); 1087 ThreadData::Snapshot(0, &process_data);
673 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, 1088 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName,
674 kMainThreadName, 1, 6, 4); 1089 kMainThreadName, 1, 6, 4);
675 } 1090 }
676 1091
677 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) { 1092 TEST_F(TrackedObjectsTest, TaskWith2NestedExclusions) {
678 if (!ThreadData::InitializeAndSetTrackingStatus( 1093 if (!ThreadData::InitializeAndSetTrackingStatus(
679 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 1094 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
1095 // Don't run the test if task tracking is not compiled in.
680 return; 1096 return;
681 } 1097 }
682 1098
683 const char kFunction[] = "TaskWith2NestedExclusions"; 1099 const char kFunction[] = "TaskWith2NestedExclusions";
684 Location location(kFunction, kFile, kLineNumber, NULL); 1100 Location location(kFunction, kFile, kLineNumber, NULL);
685 TallyABirth(location, kMainThreadName); 1101 TallyABirth(location, kMainThreadName);
686 1102
687 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1); 1103 const TrackedTime kTimePosted = TrackedTime::FromMilliseconds(1);
688 const base::TimeTicks kDelayedStartTime = base::TimeTicks(); 1104 const base::TimeTicks kDelayedStartTime = base::TimeTicks();
689 // TrackingInfo will call TallyABirth() during construction. 1105 // TrackingInfo will call TallyABirth() during construction.
(...skipping 15 matching lines...) Expand all
705 exclusion_stopwatch2.Start(); 1121 exclusion_stopwatch2.Start();
706 SetTestTime(18); 1122 SetTestTime(18);
707 exclusion_stopwatch2.Stop(); 1123 exclusion_stopwatch2.Stop();
708 } 1124 }
709 SetTestTime(25); 1125 SetTestTime(25);
710 task_stopwatch.Stop(); 1126 task_stopwatch.Stop();
711 1127
712 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch); 1128 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch);
713 1129
714 ProcessDataSnapshot process_data; 1130 ProcessDataSnapshot process_data;
715 ThreadData::Snapshot(&process_data); 1131 ThreadData::Snapshot(0, &process_data);
716 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName, 1132 ExpectSimpleProcessData(process_data, kFunction, kMainThreadName,
717 kMainThreadName, 1, 13, 4); 1133 kMainThreadName, 1, 13, 4);
718 } 1134 }
719 1135
720 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) { 1136 TEST_F(TrackedObjectsTest, TaskWithNestedExclusionWithNestedTask) {
721 if (!ThreadData::InitializeAndSetTrackingStatus( 1137 if (!ThreadData::InitializeAndSetTrackingStatus(
722 ThreadData::PROFILING_CHILDREN_ACTIVE)) { 1138 ThreadData::PROFILING_CHILDREN_ACTIVE)) {
1139 // Don't run the test if task tracking is not compiled in.
723 return; 1140 return;
724 } 1141 }
725 1142
726 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask"; 1143 const char kFunction[] = "TaskWithNestedExclusionWithNestedTask";
727 Location location(kFunction, kFile, kLineNumber, NULL); 1144 Location location(kFunction, kFile, kLineNumber, NULL);
728 1145
729 const int kSecondFakeLineNumber = 999; 1146 const int kSecondFakeLineNumber = 999;
730 1147
731 TallyABirth(location, kMainThreadName); 1148 TallyABirth(location, kMainThreadName);
732 1149
(...skipping 25 matching lines...) Expand all
758 } 1175 }
759 SetTestTime(12); 1176 SetTestTime(12);
760 exclusion_stopwatch.Stop(); 1177 exclusion_stopwatch.Stop();
761 } 1178 }
762 SetTestTime(15); 1179 SetTestTime(15);
763 task_stopwatch.Stop(); 1180 task_stopwatch.Stop();
764 1181
765 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch); 1182 ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, task_stopwatch);
766 1183
767 ProcessDataSnapshot process_data; 1184 ProcessDataSnapshot process_data;
768 ThreadData::Snapshot(&process_data); 1185 ThreadData::Snapshot(0, &process_data);
769 1186
770 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size()); 1187 ASSERT_EQ(1u, process_data.phased_process_data_snapshots.size());
771 auto it = process_data.phased_process_data_snapshots.find(0); 1188 auto it = process_data.phased_process_data_snapshots.find(0);
772 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end()); 1189 ASSERT_TRUE(it != process_data.phased_process_data_snapshots.end());
773 const ProcessDataPhaseSnapshot& process_data_phase = it->second; 1190 const ProcessDataPhaseSnapshot& process_data_phase = it->second;
774 1191
775 // The order in which the two task follow is platform-dependent. 1192 // The order in which the two task follow is platform-dependent.
776 int t0 = 1193 int t0 =
777 (process_data_phase.tasks[0].birth.location.line_number == kLineNumber) 1194 (process_data_phase.tasks[0].birth.location.line_number == kLineNumber)
778 ? 0 1195 ? 0
(...skipping 27 matching lines...) Expand all
806 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sample); 1223 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sample);
807 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sum); 1224 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sum);
808 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_max); 1225 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_max);
809 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sample); 1226 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sample);
810 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].death_thread_name); 1227 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].death_thread_name);
811 EXPECT_EQ(0u, process_data_phase.descendants.size()); 1228 EXPECT_EQ(0u, process_data_phase.descendants.size());
812 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); 1229 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id);
813 } 1230 }
814 1231
815 } // namespace tracked_objects 1232 } // namespace tracked_objects
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698