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

Side by Side Diff: chrome/test/gpu/gpu_feature_browsertest.cc

Issue 10911268: Add some TraceAnalyzer utility methods to simplify test code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/test/trace_event_analyzer.h" 10 #include "base/test/trace_event_analyzer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Have to use a new tab for the blacklist to work. 123 // Have to use a new tab for the blacklist to work.
124 RunTest(url, NULL, true); 124 RunTest(url, NULL, true);
125 125
126 ASSERT_TRUE(tracing::EndTracing(&trace_events_json_)); 126 ASSERT_TRUE(tracing::EndTracing(&trace_events_json_));
127 127
128 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); 128 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_));
129 analyzer_->AssociateBeginEndEvents(); 129 analyzer_->AssociateBeginEndEvents();
130 TraceEventVector events; 130 TraceEventVector events;
131 131
132 if (expectations & EXPECT_NO_GPU_SWAP_BUFFERS) { 132 if (expectations & EXPECT_NO_GPU_SWAP_BUFFERS) {
133 EXPECT_EQ(analyzer_->FindEvents(Query::EventName() == 133 EXPECT_EQ(analyzer_->FindEvents(Query::EventNameIs("SwapBuffers"),
134 Query::String("SwapBuffers"), &events), 134 &events), size_t(0));
135 size_t(0));
136 } 135 }
137 136
138 // Check for swap buffers if expected: 137 // Check for swap buffers if expected:
139 if (expectations & EXPECT_GPU_SWAP_BUFFERS) { 138 if (expectations & EXPECT_GPU_SWAP_BUFFERS) {
140 EXPECT_GT(analyzer_->FindEvents(Query::EventName() == 139 EXPECT_GT(analyzer_->FindEvents(Query::EventNameIs("SwapBuffers"),
141 Query::String("SwapBuffers"), &events), 140 &events), size_t(0));
142 size_t(0));
143 } 141 }
144 } 142 }
145 143
146 // Trigger a resize of the chrome window, and use tracing to wait for the 144 // Trigger a resize of the chrome window, and use tracing to wait for the
147 // given |wait_event|. 145 // given |wait_event|.
148 bool ResizeAndWait(const gfx::Rect& new_bounds, 146 bool ResizeAndWait(const gfx::Rect& new_bounds,
149 const char* trace_categories, 147 const char* trace_categories,
150 const char* wait_category, 148 const char* wait_category,
151 const char* wait_event) { 149 const char* wait_event) {
152 if (!tracing::BeginTracingWithWatch(trace_categories, wait_category, 150 if (!tracing::BeginTracingWithWatch(trace_categories, wait_category,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, RafNoDamage) { 406 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, RafNoDamage) {
409 trace_categories_ = "-test_*"; 407 trace_categories_ = "-test_*";
410 const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); 408 const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html"));
411 RunTest(url, GpuResultFlags(0)); 409 RunTest(url, GpuResultFlags(0));
412 410
413 if (!analyzer_.get()) 411 if (!analyzer_.get())
414 return; 412 return;
415 413
416 // Search for matching name on begin event or async_begin event (any begin). 414 // Search for matching name on begin event or async_begin event (any begin).
417 Query query_raf = 415 Query query_raf =
418 (Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_BEGIN) || 416 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) ||
419 Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && 417 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) &&
420 Query::EventName() == Query::String("___RafWithNoDamage___"); 418 Query::EventNameIs("___RafWithNoDamage___");
421 TraceEventVector events; 419 TraceEventVector events;
422 size_t num_events = analyzer_->FindEvents(query_raf, &events); 420 size_t num_events = analyzer_->FindEvents(query_raf, &events);
423 421
424 trace_analyzer::RateStats stats; 422 trace_analyzer::RateStats stats;
425 trace_analyzer::RateStatsOptions stats_options; 423 trace_analyzer::RateStatsOptions stats_options;
426 stats_options.trim_min = stats_options.trim_max = num_events / 10; 424 stats_options.trim_min = stats_options.trim_max = num_events / 10;
427 EXPECT_TRUE(trace_analyzer::GetRateStats(events, &stats, &stats_options)); 425 EXPECT_TRUE(trace_analyzer::GetRateStats(events, &stats, &stats_options));
428 426
429 LOG(INFO) << "Number of RAFs: " << num_events << 427 LOG(INFO) << "Number of RAFs: " << num_events <<
430 " Mean: " << stats.mean_us << 428 " Mean: " << stats.mean_us <<
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 i, offsets[i], events[j]->GetKnownArgAsInt("width"), 505 i, offsets[i], events[j]->GetKnownArgAsInt("width"),
508 events[j]->GetKnownArgAsInt("height"), this_num_creates); 506 events[j]->GetKnownArgAsInt("height"), this_num_creates);
509 } 507 }
510 } 508 }
511 509
512 EXPECT_EQ(surface_pixels_per_window_pixel, num_creates); 510 EXPECT_EQ(surface_pixels_per_window_pixel, num_creates);
513 } 511 }
514 #endif 512 #endif
515 513
516 } // namespace anonymous 514 } // namespace anonymous
OLDNEW
« no previous file with comments | « base/test/trace_event_analyzer_unittest.cc ('k') | chrome/test/perf/frame_rate/frame_rate_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698