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

Side by Side Diff: components/metrics/leak_detector/call_stack_table_unittest.cc

Issue 2417403002: Revert of Leak reports collect information about the last uptrend (Closed)
Patch Set: Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/metrics/leak_detector/call_stack_table.h" 5 #include "components/metrics/leak_detector/call_stack_table.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 table.GetTopCallStacks(&top_two); 353 table.GetTopCallStacks(&top_two);
354 ASSERT_EQ(2U, top_two.size()); 354 ASSERT_EQ(2U, top_two.size());
355 iter = top_two.begin(); 355 iter = top_two.begin();
356 EXPECT_EQ(72, iter->count); 356 EXPECT_EQ(72, iter->count);
357 EXPECT_EQ(stack3_, iter->value.call_stack()); 357 EXPECT_EQ(stack3_, iter->value.call_stack());
358 ++iter; 358 ++iter;
359 EXPECT_EQ(64, iter->count); 359 EXPECT_EQ(64, iter->count);
360 EXPECT_EQ(stack2_, iter->value.call_stack()); 360 EXPECT_EQ(stack2_, iter->value.call_stack());
361 } 361 }
362 362
363 TEST_F(CallStackTableTest, GetLastUptrendInfo) {
364 CallStackTable table(kDefaultLeakThreshold);
365
366 // Add some |stack0_| and |stack1_|.
367 for (int i = 0; i < 60; ++i)
368 table.Add(stack0_);
369 for (int i = 0; i < 60; ++i)
370 table.Add(stack1_);
371 table.UpdateLastDropInfo(100);
372
373 size_t timestamp_delta;
374 uint32_t count_delta;
375 table.GetLastUptrendInfo(stack0_, 100, &timestamp_delta, &count_delta);
376 EXPECT_EQ(0U, timestamp_delta);
377 EXPECT_EQ(0U, count_delta);
378
379 // Remove |stack0_| and add |stack1_|.
380 for (int i = 0; i < 30; ++i)
381 table.Remove(stack0_);
382 for (int i = 0; i < 30; ++i)
383 table.Add(stack1_);
384 table.UpdateLastDropInfo(200);
385
386 table.GetLastUptrendInfo(stack0_, 200, &timestamp_delta, &count_delta);
387 EXPECT_EQ(0U, timestamp_delta);
388 EXPECT_EQ(0U, count_delta);
389
390 table.GetLastUptrendInfo(stack1_, 200, &timestamp_delta, &count_delta);
391 EXPECT_EQ(100U, timestamp_delta);
392 EXPECT_EQ(30U, count_delta);
393
394 // Check if previous drop of |stack0_| was recorded and introduce |stack2_|.
395 for (int i = 0; i < 30; ++i)
396 table.Add(stack0_);
397 for (int i = 0; i < 60; ++i)
398 table.Add(stack2_);
399 table.UpdateLastDropInfo(300);
400
401 table.GetLastUptrendInfo(stack0_, 300, &timestamp_delta, &count_delta);
402 EXPECT_EQ(100U, timestamp_delta);
403 EXPECT_EQ(30U, count_delta);
404
405 table.GetLastUptrendInfo(stack2_, 300, &timestamp_delta, &count_delta);
406 EXPECT_EQ(0U, timestamp_delta);
407 EXPECT_EQ(0U, count_delta);
408
409 // Introduce more variation between updates. Decrease |stack2_| to 0.
410 // All the history for |stack2_| should be forgotten.
411 for (int i = 0; i < 30; ++i)
412 table.Add(stack0_);
413 for (int i = 0; i < 40; ++i)
414 table.Remove(stack0_);
415 for (int i = 0; i < 40; ++i)
416 table.Add(stack1_);
417 for (int i = 0; i < 30; ++i)
418 table.Remove(stack1_);
419 for (int i = 0; i < 30; ++i)
420 table.Remove(stack2_);
421 for (int i = 0; i < 30; ++i)
422 table.Remove(stack2_);
423 table.UpdateLastDropInfo(400);
424
425 table.GetLastUptrendInfo(stack0_, 400, &timestamp_delta, &count_delta);
426 EXPECT_EQ(0U, timestamp_delta);
427 EXPECT_EQ(0U, count_delta);
428
429 table.GetLastUptrendInfo(stack1_, 400, &timestamp_delta, &count_delta);
430 EXPECT_EQ(300U, timestamp_delta);
431 EXPECT_EQ(40U, count_delta);
432
433 table.GetLastUptrendInfo(stack2_, 400, &timestamp_delta, &count_delta);
434 EXPECT_EQ(400U, timestamp_delta);
435 EXPECT_EQ(0U, count_delta);
436
437 // Make a 0-sum sequence for |stack0_|. Introduce |stack2_| again.
438 for (int i = 0; i < 30; ++i)
439 table.Add(stack0_);
440 for (int i = 0; i < 30; ++i)
441 table.Remove(stack0_);
442 for (int i = 0; i < 40; ++i)
443 table.Add(stack2_);
444 for (int i = 0; i < 30; ++i)
445 table.Remove(stack2_);
446 table.UpdateLastDropInfo(500);
447
448 table.GetLastUptrendInfo(stack0_, 500, &timestamp_delta, &count_delta);
449 EXPECT_EQ(100U, timestamp_delta);
450 EXPECT_EQ(0U, count_delta);
451
452 table.GetLastUptrendInfo(stack2_, 500, &timestamp_delta, &count_delta);
453 EXPECT_EQ(0U, timestamp_delta);
454 EXPECT_EQ(0U, count_delta);
455 }
456
457 } // namespace leak_detector 363 } // namespace leak_detector
458 } // namespace metrics 364 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/leak_detector/call_stack_table.cc ('k') | components/metrics/leak_detector/leak_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698