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

Side by Side Diff: content/renderer/devtools/v8_sampling_profiler_browsertest.cc

Issue 1165673002: [Startup Tracing] Hook up TraceConfig and remove CategoryFilter & TraceOptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 6 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "content/public/test/render_view_test.h" 8 #include "content/public/test/render_view_test.h"
9 #include "content/renderer/devtools/v8_sampling_profiler.h" 9 #include "content/renderer/devtools/v8_sampling_profiler.h"
10 10
11 using base::DictionaryValue; 11 using base::DictionaryValue;
12 using base::ListValue; 12 using base::ListValue;
13 using base::Value; 13 using base::Value;
14 using base::trace_event::CategoryFilter; 14 using base::trace_event::TraceConfig;
15 using base::trace_event::TraceLog; 15 using base::trace_event::TraceLog;
16 using base::trace_event::TraceOptions;
17 using base::trace_event::TraceResultBuffer; 16 using base::trace_event::TraceResultBuffer;
18 17
19 namespace content { 18 namespace content {
20 19
21 class V8SamplingProfilerTest : public RenderViewTest { 20 class V8SamplingProfilerTest : public RenderViewTest {
22 public: 21 public:
23 void SetUp() override { 22 void SetUp() override {
24 RenderViewTest::SetUp(); 23 RenderViewTest::SetUp();
25 sampling_profiler_.reset(new V8SamplingProfiler(true)); 24 sampling_profiler_.reset(new V8SamplingProfiler(true));
26 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); 25 trace_buffer_.SetOutputCallback(json_output_.GetCallback());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 74
76 if (!has_more_events) 75 if (!has_more_events)
77 flush_complete_event->Signal(); 76 flush_complete_event->Signal();
78 } 77 }
79 78
80 void CollectTrace(int code_added_events, int sample_events) { 79 void CollectTrace(int code_added_events, int sample_events) {
81 TraceLog* trace_log = TraceLog::GetInstance(); 80 TraceLog* trace_log = TraceLog::GetInstance();
82 sampling_profiler_->EnableSamplingEventForTesting(code_added_events, 81 sampling_profiler_->EnableSamplingEventForTesting(code_added_events,
83 sample_events); 82 sample_events);
84 trace_log->SetEnabled( 83 trace_log->SetEnabled(
85 CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")), 84 TraceConfig(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), ""),
86 TraceLog::RECORDING_MODE, TraceOptions()); 85 TraceLog::RECORDING_MODE);
87 base::RunLoop().RunUntilIdle(); 86 base::RunLoop().RunUntilIdle();
88 KickV8(); // Make a call to V8 so it can invoke interrupt request 87 KickV8(); // Make a call to V8 so it can invoke interrupt request
89 // callbacks. 88 // callbacks.
90 base::RunLoop().RunUntilIdle(); 89 base::RunLoop().RunUntilIdle();
91 sampling_profiler_->WaitSamplingEventForTesting(); 90 sampling_profiler_->WaitSamplingEventForTesting();
92 trace_log->SetDisabled(); 91 trace_log->SetDisabled();
93 SyncFlush(trace_log); 92 SyncFlush(trace_log);
94 } 93 }
95 94
96 int CountEvents(const std::string& name) const { 95 int CountEvents(const std::string& name) const {
(...skipping 18 matching lines...) Expand all
115 base::Lock lock_; 114 base::Lock lock_;
116 115
117 ListValue trace_parsed_; 116 ListValue trace_parsed_;
118 TraceResultBuffer trace_buffer_; 117 TraceResultBuffer trace_buffer_;
119 TraceResultBuffer::SimpleOutput json_output_; 118 TraceResultBuffer::SimpleOutput json_output_;
120 }; 119 };
121 120
122 TEST_F(V8SamplingProfilerTest, V8SamplingEventFired) { 121 TEST_F(V8SamplingProfilerTest, V8SamplingEventFired) {
123 sampling_profiler_->EnableSamplingEventForTesting(0, 0); 122 sampling_profiler_->EnableSamplingEventForTesting(0, 0);
124 TraceLog::GetInstance()->SetEnabled( 123 TraceLog::GetInstance()->SetEnabled(
125 CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")), 124 TraceConfig(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), ""),
126 TraceLog::RECORDING_MODE, TraceOptions()); 125 TraceLog::RECORDING_MODE);
127 base::RunLoop().RunUntilIdle(); 126 base::RunLoop().RunUntilIdle();
128 sampling_profiler_->WaitSamplingEventForTesting(); 127 sampling_profiler_->WaitSamplingEventForTesting();
129 TraceLog::GetInstance()->SetDisabled(); 128 TraceLog::GetInstance()->SetDisabled();
130 } 129 }
131 130
132 TEST_F(V8SamplingProfilerTest, V8SamplingJitCodeEventsCollected) { 131 TEST_F(V8SamplingProfilerTest, V8SamplingJitCodeEventsCollected) {
133 CollectTrace(1, 0); 132 CollectTrace(1, 0);
134 int jit_code_added_events_count = CountEvents("JitCodeAdded"); 133 int jit_code_added_events_count = CountEvents("JitCodeAdded");
135 CHECK_LT(0, jit_code_added_events_count); 134 CHECK_LT(0, jit_code_added_events_count);
136 base::RunLoop().RunUntilIdle(); 135 base::RunLoop().RunUntilIdle();
137 } 136 }
138 137
139 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) { 138 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) {
140 CollectTrace(0, 1); 139 CollectTrace(0, 1);
141 int sample_events_count = CountEvents("V8Sample"); 140 int sample_events_count = CountEvents("V8Sample");
142 CHECK_LT(0, sample_events_count); 141 CHECK_LT(0, sample_events_count);
143 base::RunLoop().RunUntilIdle(); 142 base::RunLoop().RunUntilIdle();
144 } 143 }
145 144
146 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/devtools/v8_sampling_profiler.cc ('k') | mandoline/app/desktop/launcher_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698