• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "src/profiling/memory/sampler.h"
18 
19 #include "gtest/gtest.h"
20 
21 #include <thread>
22 
23 namespace perfetto {
24 namespace profiling {
25 namespace {
26 
TEST(SamplerTest,TestLarge)27 TEST(SamplerTest, TestLarge) {
28   Sampler sampler(512);
29   EXPECT_EQ(sampler.SampleSize(1024), 1024);
30 }
31 
TEST(SamplerTest,TestSmall)32 TEST(SamplerTest, TestSmall) {
33   Sampler sampler(512);
34   EXPECT_EQ(sampler.SampleSize(511), 512);
35 }
36 
TEST(SamplerTest,TestSequence)37 TEST(SamplerTest, TestSequence) {
38   Sampler sampler(1);
39   EXPECT_EQ(sampler.SampleSize(3), 3);
40   EXPECT_EQ(sampler.SampleSize(7), 7);
41   EXPECT_EQ(sampler.SampleSize(5), 5);
42 }
43 
44 }  // namespace
45 }  // namespace profiling
46 }  // namespace perfetto
47