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

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

Issue 2973543002: Record task durations on Renderer Main & Compositor threads.
Patch Set: Fix layering issues. Created 3 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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/debug/task_annotator.h" 5 #include "base/debug/task_annotator.h"
6 #include "base/base_switches.h"
6 #include "base/bind.h" 7 #include "base/bind.h"
7 #include "base/pending_task.h" 8 #include "base/pending_task.h"
9 #include "base/test/histogram_tester.h"
10 #include "base/test/scoped_command_line.h"
8 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
9 12
10 namespace base { 13 namespace base {
11 namespace debug { 14 namespace debug {
12 namespace { 15 namespace {
13 16
14 void TestTask(int* result) { 17 void TestTask(int* result) {
15 *result = 123; 18 *result = 123;
16 } 19 }
17 20
18 } // namespace 21 } // namespace
19 22
20 TEST(TaskAnnotatorTest, QueueAndRunTask) { 23 TEST(TaskAnnotatorTest, QueueAndRunTask) {
21 int result = 0; 24 int result = 0;
22 PendingTask pending_task(FROM_HERE, BindOnce(&TestTask, &result)); 25 PendingTask pending_task(FROM_HERE, BindOnce(&TestTask, &result));
23 26
24 TaskAnnotator annotator; 27 TaskAnnotator annotator;
25 annotator.DidQueueTask("TaskAnnotatorTest::Queue", pending_task); 28 annotator.DidQueueTask("TaskAnnotatorTest::Queue", pending_task);
26 EXPECT_EQ(0, result); 29 EXPECT_EQ(0, result);
27 annotator.RunTask("TaskAnnotatorTest::Queue", &pending_task); 30 annotator.RunTask("TaskAnnotatorTest::Queue", &pending_task);
28 EXPECT_EQ(123, result); 31 EXPECT_EQ(123, result);
29 } 32 }
30 33
34 TEST(TaskAnnotatorTest, TaskTimeHistogram) {
35 base::test::ScopedCommandLine scoped_command_line;
36 base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
37 command_line->AppendSwitchASCII(switches::kProfilerTiming, "0");
38
39 // --profiler-timing=0
40 base::PlatformThread::SetName("Compositor");
41
42 HistogramTester histogram_tester;
43 TaskAnnotator annotator;
44
45 int result = 0;
46 PendingTask pending_task(FROM_HERE, BindOnce(&TestTask, &result));
47
48 annotator.DidQueueTask("TaskAnnotatorTest::Queue", pending_task);
49 annotator.RunTask("TaskAnnotatorTest::Queue", &pending_task);
50
51 histogram_tester.ExpectTotalCount("Scheduling.TaskTime.Compositor", 1);
52 }
53
31 } // namespace debug 54 } // namespace debug
32 } // namespace base 55 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698