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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 18587004: Add a sampling tracing to RenderWidget::DoDeferredUpdate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 1795
1796 event_watch_notification_ = 0; 1796 event_watch_notification_ = 0;
1797 TraceLog::GetInstance()->SetEnabled( 1797 TraceLog::GetInstance()->SetEnabled(
1798 CategoryFilter("*"), 1798 CategoryFilter("*"),
1799 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | 1799 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL |
1800 TraceLog::ENABLE_SAMPLING)); 1800 TraceLog::ENABLE_SAMPLING));
1801 1801
1802 WaitableEvent* sampled = new WaitableEvent(false, false); 1802 WaitableEvent* sampled = new WaitableEvent(false, false);
1803 TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled); 1803 TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled);
1804 1804
1805 TRACE_EVENT_SAMPLE_STATE(1, "cc", "Stuff"); 1805 TRACE_EVENT_SAMPLING_STATE0("cc", "Stuff");
1806 sampled->Wait(); 1806 sampled->Wait();
1807 TRACE_EVENT_SAMPLE_STATE(1, "cc", "Things"); 1807 TRACE_EVENT_SAMPLING_STATE0("cc", "Things");
1808 sampled->Wait(); 1808 sampled->Wait();
1809 1809
1810 EndTraceAndFlush(); 1810 EndTraceAndFlush();
1811 1811
1812 // Make sure we hit at least once. 1812 // Make sure we hit at least once.
1813 EXPECT_TRUE(FindNamePhase("Stuff", "P")); 1813 EXPECT_TRUE(FindNamePhase("Stuff", "P"));
1814 EXPECT_TRUE(FindNamePhase("Things", "P")); 1814 EXPECT_TRUE(FindNamePhase("Things", "P"));
1815 } 1815 }
1816 #endif // !CHROME_SPLIT_DLL 1816 #endif // !CHROME_SPLIT_DLL
1817 1817
1818 // Not supported in split dll build. http://crbug.com/237249
1819 #if !defined(CHROME_SPLIT_DLL)
1820 TEST_F(TraceEventTestFixture, TraceSamplingScope) {
1821 ManualTestSetUp();
1822
1823 event_watch_notification_ = 0;
1824 TraceLog::GetInstance()->SetEnabled(
1825 CategoryFilter("*"),
1826 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL |
1827 TraceLog::ENABLE_SAMPLING));
1828
1829 WaitableEvent* sampled = new WaitableEvent(false, false);
1830 TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled);
1831
1832 TraceEventSamplingState0Scope scope("AAA");
1833 sampled->Wait();
1834 {
1835 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "AAA");
1836 TraceEventSamplingState0Scope scope2("BBB");
1837 sampled->Wait();
1838 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "BBB");
1839 }
1840 sampled->Wait();
1841 {
1842 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "AAA");
1843 TraceEventSamplingState0Scope scope2("CCC");
1844 sampled->Wait();
1845 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "CCC");
1846 }
1847 sampled->Wait();
1848 {
1849 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "AAA");
1850 TraceEventSamplingState0Scope::forceCurrent("DDD");
1851 sampled->Wait();
1852 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "DDD");
1853 }
1854 sampled->Wait();
1855 EXPECT_STREQ(TraceEventSamplingState0Scope::current(), "DDD");
1856
1857 EndTraceAndFlush();
1858 }
1859 #endif // !CHROME_SPLIT_DLL
1860
1818 class MyData : public base::debug::ConvertableToTraceFormat { 1861 class MyData : public base::debug::ConvertableToTraceFormat {
1819 public: 1862 public:
1820 MyData() {} 1863 MyData() {}
1821 virtual ~MyData() {} 1864 virtual ~MyData() {}
1822 1865
1823 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { 1866 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
1824 out->append("{\"foo\":1}"); 1867 out->append("{\"foo\":1}");
1825 } 1868 }
1826 1869
1827 private: 1870 private:
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2140 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
2098 " bad_category ")); 2141 " bad_category "));
2099 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2142 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
2100 "")); 2143 ""));
2101 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2144 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
2102 "good_category")); 2145 "good_category"));
2103 } 2146 }
2104 2147
2105 } // namespace debug 2148 } // namespace debug
2106 } // namespace base 2149 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698