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

Side by Side Diff: third_party/WebKit/Source/platform/HistogramTest.cpp

Issue 1852633002: Add UMA stats for time in paint+layout, compositing, paint invalidation and paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/Histogram.h"
6
7 #include "base/metrics/histogram_samples.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace blink {
11
12 class ScopedUsHistogramTimerTest : public ::testing::Test {
13 public:
14 static void advanceClock(double microseconds)
15 {
16 s_timeElapsed += microseconds;
17 }
18
19 protected:
20 static double returnMockTime()
21 {
22 return s_timeElapsed;
23 }
24
25 virtual void SetUp()
26 {
27 s_timeElapsed = 0.0;
28 m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime);
29 }
30
31 virtual void TearDown()
32 {
33 setTimeFunctionsForTesting(m_originalTimeFunction);
34 }
35
36 private:
37 static double s_timeElapsed;
38 TimeFunction m_originalTimeFunction;
39 };
40
41 double ScopedUsHistogramTimerTest::s_timeElapsed;
42
43 class TestCustomCountHistogram : public CustomCountHistogram {
44 public:
45 TestCustomCountHistogram(const char* name, base::HistogramBase::Sample min, base::HistogramBase::Sample max, int32_t bucketCount)
46 : CustomCountHistogram(name, min, max, bucketCount) {}
47
48 base::HistogramBase* histogram() { return m_histogram; }
49 };
50
51 TEST_F(ScopedUsHistogramTimerTest, Basic)
52 {
53 TestCustomCountHistogram scopedUsCounter("test", 0, 10000000, 50);
54 {
55 ScopedUsHistogramTimer timer(scopedUsCounter);
56 advanceClock(0.5);
57 }
58 // 0.5s == 500000us
59 EXPECT_EQ(500000, scopedUsCounter.histogram()->SnapshotSamples()->sum());
60 }
61
62 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Histogram.h ('k') | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698