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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 23556003: Implement about:tracing UI for the sampling profiler (Chromium part) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | components/tracing/child_trace_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index b5909845f27c1053b29b68278db598b1e7a14530..1ad53f4c78231f01a75823421a5df4f4f7709147 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -90,6 +90,12 @@ class TraceEventTestFixture : public testing::Test {
base::Unretained(this)));
}
+ void FlushContinuousSampling() {
+ TraceLog::GetInstance()->FlushContinuousSamplingTracing(
+ base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
+ base::Unretained(this)));
+ }
+
virtual void SetUp() OVERRIDE {
const char* name = PlatformThread::GetName();
old_thread_name_ = name ? strdup(name) : NULL;
@@ -1737,6 +1743,56 @@ TEST_F(TraceEventTestFixture, TraceSamplingScope) {
EndTraceAndFlush();
}
+TEST_F(TraceEventTestFixture, TraceContinuousSampling) {
+ event_watch_notification_ = 0;
+ TraceLog::GetInstance()->SetContinuousSamplingEnabled();
+
+ WaitableEvent* sampled = new WaitableEvent(false, false);
+ TraceLog::GetInstance()->InstallWaitableEventForContinuousSamplingTesting(
+ sampled);
+
+ TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA");
+ sampled->Wait();
+ TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB");
+ sampled->Wait();
+
+ FlushContinuousSampling();
+
+ // Make sure we can get the profiled data.
+ EXPECT_TRUE(FindNamePhase("AAA", "P"));
+ EXPECT_TRUE(FindNamePhase("BBB", "P"));
+
+ Clear();
+
+ TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "CCC");
+ sampled->Wait();
+ TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "DDD");
+ sampled->Wait();
+
+ FlushContinuousSampling();
+
+ // Make sure the profiled data is accumulated.
+ EXPECT_TRUE(FindNamePhase("AAA", "P"));
+ EXPECT_TRUE(FindNamePhase("BBB", "P"));
+ EXPECT_TRUE(FindNamePhase("CCC", "P"));
+ EXPECT_TRUE(FindNamePhase("DDD", "P"));
+
+ Clear();
+
+ TraceLog::GetInstance()->SetContinuousSamplingDisabled();
+
+ FlushContinuousSampling();
+
+ // Make sure disabling the continuous sampling thread clears
+ // the profiled data.
+ EXPECT_FALSE(FindNamePhase("AAA", "P"));
+ EXPECT_FALSE(FindNamePhase("BBB", "P"));
+ EXPECT_FALSE(FindNamePhase("CCC", "P"));
+ EXPECT_FALSE(FindNamePhase("DDD", "P"));
+
+ Clear();
+}
+
class MyData : public base::debug::ConvertableToTraceFormat {
public:
MyData() {}
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | components/tracing/child_trace_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698