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

Side by Side Diff: base/test/trace_event_analyzer_unittest.cc

Issue 9580021: Add test for RAF-spinning with no damage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: marking test flaky for initial commit to be safe Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/data/gpu/feature_raf_no_damage.html » ('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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/test/trace_event_analyzer.h" 6 #include "base/test/trace_event_analyzer.h"
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace trace_analyzer { 10 namespace trace_analyzer {
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 637
638 // Test GetRateStats. 638 // Test GetRateStats.
639 TEST_F(TraceEventAnalyzerTest, RateStats) { 639 TEST_F(TraceEventAnalyzerTest, RateStats) {
640 std::vector<TraceEvent> events; 640 std::vector<TraceEvent> events;
641 events.reserve(100); 641 events.reserve(100);
642 TraceEventVector event_ptrs; 642 TraceEventVector event_ptrs;
643 TraceEvent event; 643 TraceEvent event;
644 event.timestamp = 0.0; 644 event.timestamp = 0.0;
645 double little_delta = 1.0; 645 double little_delta = 1.0;
646 double big_delta = 10.0; 646 double big_delta = 10.0;
647 double tiny_delta = 0.1;
647 RateStats stats; 648 RateStats stats;
649 RateStatsOptions options;
648 650
651 // Insert 10 events, each apart by little_delta.
649 for (int i = 0; i < 10; ++i) { 652 for (int i = 0; i < 10; ++i) {
650 event.timestamp += little_delta; 653 event.timestamp += little_delta;
651 events.push_back(event); 654 events.push_back(event);
652 event_ptrs.push_back(&events.back()); 655 event_ptrs.push_back(&events.back());
653 } 656 }
654 657
655 ASSERT_TRUE(GetRateStats(event_ptrs, &stats)); 658 ASSERT_TRUE(GetRateStats(event_ptrs, &stats, NULL));
656 EXPECT_EQ(little_delta, stats.mean_us); 659 EXPECT_EQ(little_delta, stats.mean_us);
657 EXPECT_EQ(little_delta, stats.min_us); 660 EXPECT_EQ(little_delta, stats.min_us);
658 EXPECT_EQ(little_delta, stats.max_us); 661 EXPECT_EQ(little_delta, stats.max_us);
659 EXPECT_EQ(0.0, stats.standard_deviation_us); 662 EXPECT_EQ(0.0, stats.standard_deviation_us);
660 663
664 // Add an event apart by big_delta.
661 event.timestamp += big_delta; 665 event.timestamp += big_delta;
662 events.push_back(event); 666 events.push_back(event);
663 event_ptrs.push_back(&events.back()); 667 event_ptrs.push_back(&events.back());
664 668
665 ASSERT_TRUE(GetRateStats(event_ptrs, &stats)); 669 ASSERT_TRUE(GetRateStats(event_ptrs, &stats, NULL));
666 EXPECT_LT(little_delta, stats.mean_us); 670 EXPECT_LT(little_delta, stats.mean_us);
667 EXPECT_EQ(little_delta, stats.min_us); 671 EXPECT_EQ(little_delta, stats.min_us);
668 EXPECT_EQ(big_delta, stats.max_us); 672 EXPECT_EQ(big_delta, stats.max_us);
669 EXPECT_LT(0.0, stats.standard_deviation_us); 673 EXPECT_LT(0.0, stats.standard_deviation_us);
670 674
675 // Trim off the biggest delta and verify stats.
676 options.trim_min = 0;
677 options.trim_max = 1;
678 ASSERT_TRUE(GetRateStats(event_ptrs, &stats, &options));
679 EXPECT_EQ(little_delta, stats.mean_us);
680 EXPECT_EQ(little_delta, stats.min_us);
681 EXPECT_EQ(little_delta, stats.max_us);
682 EXPECT_EQ(0.0, stats.standard_deviation_us);
683
684 // Add an event apart by tiny_delta.
685 event.timestamp += tiny_delta;
686 events.push_back(event);
687 event_ptrs.push_back(&events.back());
688
689 // Trim off both the biggest and tiniest delta and verify stats.
690 options.trim_min = 1;
691 options.trim_max = 1;
692 ASSERT_TRUE(GetRateStats(event_ptrs, &stats, &options));
693 EXPECT_EQ(little_delta, stats.mean_us);
694 EXPECT_EQ(little_delta, stats.min_us);
695 EXPECT_EQ(little_delta, stats.max_us);
696 EXPECT_EQ(0.0, stats.standard_deviation_us);
697
698 // Verify smallest allowed number of events.
671 TraceEventVector few_event_ptrs; 699 TraceEventVector few_event_ptrs;
672 few_event_ptrs.push_back(&event); 700 few_event_ptrs.push_back(&event);
673 few_event_ptrs.push_back(&event); 701 few_event_ptrs.push_back(&event);
674 ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats)); 702 ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats, NULL));
675 few_event_ptrs.push_back(&event); 703 few_event_ptrs.push_back(&event);
676 ASSERT_TRUE(GetRateStats(few_event_ptrs, &stats)); 704 ASSERT_TRUE(GetRateStats(few_event_ptrs, &stats, NULL));
705
706 // Trim off more than allowed and verify failure.
707 options.trim_min = 0;
708 options.trim_max = 1;
709 ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats, &options));
677 } 710 }
678 711
679 // Test FindFirstOf and FindLastOf. 712 // Test FindFirstOf and FindLastOf.
680 TEST_F(TraceEventAnalyzerTest, FindOf) { 713 TEST_F(TraceEventAnalyzerTest, FindOf) {
681 size_t num_events = 100; 714 size_t num_events = 100;
682 size_t index = 0; 715 size_t index = 0;
683 TraceEventVector event_ptrs; 716 TraceEventVector event_ptrs;
684 EXPECT_FALSE(FindFirstOf(event_ptrs, Query::Bool(true), 0, &index)); 717 EXPECT_FALSE(FindFirstOf(event_ptrs, Query::Bool(true), 0, &index));
685 EXPECT_FALSE(FindFirstOf(event_ptrs, Query::Bool(true), 10, &index)); 718 EXPECT_FALSE(FindFirstOf(event_ptrs, Query::Bool(true), 10, &index));
686 EXPECT_FALSE(FindLastOf(event_ptrs, Query::Bool(true), 0, &index)); 719 EXPECT_FALSE(FindLastOf(event_ptrs, Query::Bool(true), 0, &index));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); 818 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true)));
786 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), 819 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true),
787 1, num_events)); 820 1, num_events));
788 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); 821 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one));
789 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); 822 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one));
790 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); 823 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named));
791 } 824 }
792 825
793 826
794 } // namespace trace_analyzer 827 } // namespace trace_analyzer
OLDNEW
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/data/gpu/feature_raf_no_damage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698