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

Unified Diff: components/scheduler/renderer/renderer_task_duration_unittest.cc

Issue 2184023002: Report the duration of sampled tasks with histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: components/scheduler/renderer/renderer_task_duration_unittest.cc
diff --git a/components/scheduler/renderer/renderer_task_duration_unittest.cc b/components/scheduler/renderer/renderer_task_duration_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c7823ed069b234403c50ee6ee19ddc2f125314c
--- /dev/null
+++ b/components/scheduler/renderer/renderer_task_duration_unittest.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/scheduler/renderer/renderer_task_duration.h"
+
+#include "base/test/histogram_tester.h"
+#include "base/metrics/histogram_macros.h"
majidvp 2016/07/27 13:50:59 histogram_macros.h seems to be an unnecessary incl
sunyunjia 2016/07/27 17:28:43 Done.
+#include "testing/gmock/include/gmock/gmock.h"
majidvp 2016/07/27 13:50:59 ditto gmock.h
sunyunjia 2016/07/27 17:28:43 Done.
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace scheduler {
+typedef testing::Test RendererTaskDurationTest;
+TEST_F(RendererTaskDurationTest, LoggingDuration) {
majidvp 2016/07/27 13:50:59 Using a text fixture is not necessary here. You ca
sunyunjia 2016/07/27 17:28:43 Done.
+ base::HistogramTester tester;
+
+ RendererTaskDuration rtd;
+ for (int i = 1; i <= rtd.kSampleInterval + 1; ++i) {
majidvp 2016/07/27 13:50:59 Please spell out 100 in the test rather than using
sunyunjia 2016/07/27 17:28:43 Done.
+ int num = i % rtd.kSampleInterval;
+ int msecond = 10 * 1000 / rtd.kSampleInterval * num + 1;
majidvp 2016/07/27 13:50:59 s/msceond/milliseconds/
majidvp 2016/07/27 13:50:59 This expression seems a bit too overcomplicated fo
sunyunjia 2016/07/27 17:28:43 Done.
sunyunjia 2016/07/27 17:28:43 Done.
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(msecond);
+ rtd.ReportSampleDuration(duration);
+ }
+ tester.ExpectUniqueSample("RendererScheduler.TaskDuration", 1, 1);
majidvp 2016/07/27 13:50:59 Why are we asserting for 1 here? It is hard to cor
sunyunjia 2016/07/27 17:28:43 Done.
+}
+}

Powered by Google App Engine
This is Rietveld 408576698