OSDN Git Service

219db06a428a1238133d730bbbf473a7c5ac7d3e
[android-x86/system-extras.git] / perfprofd / config.h
1 /*
2  *
3  * Copyright 2015, The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_
19 #define SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_
20
21 #include <cstdint>
22 #include <string>
23
24 #include <unistd.h>
25
26 struct Config {
27   virtual ~Config() {}
28
29   // Average number of seconds between perf profile collections (if
30   // set to 100, then over time we want to see a perf profile
31   // collected every 100 seconds). The actual time within the interval
32   // for the collection is chosen randomly.
33   uint32_t collection_interval_in_s = 14400;
34   // Use the specified fixed seed for random number generation (unit
35   // testing)
36   uint32_t use_fixed_seed = 0;
37   // For testing purposes, number of times to iterate through main
38   // loop.  Value of zero indicates that we should loop forever.
39   uint32_t main_loop_iterations = 0;
40
41   // The pid of the process to profile. May be negative, in which case
42   // the whole system will be profiled.
43   int32_t process = -1;
44
45   // Destination directory (where to write profiles). This location
46   // chosen since it is accessible to the uploader service.
47   std::string destination_directory = "/data/misc/perfprofd";
48   // Config directory (where to read configs).
49   std::string config_directory = "/data/data/com.google.android.gms/files";
50   // Full path to 'perf' executable.
51   std::string perf_path = "/system/xbin/simpleperf";
52
53   // Desired sampling period (passed to perf -c option). Small
54   // sampling periods can perturb the collected profiles, so enforce
55   // min/max.
56   uint32_t sampling_period = 5000;
57   // Length of time to collect samples (number of seconds for 'perf
58   // record -a' run).
59   uint32_t sample_duration_in_s = 2;
60
61   // If this parameter is non-zero it will cause perfprofd to
62   // exit immediately if the build type is not userdebug or eng.
63   // Currently defaults to 1 (true).
64   bool only_debug_build = true;
65
66   // If the "mpdecision" service is running at the point we are ready
67   // to kick off a profiling run, then temporarily disable the service
68   // and hard-wire all cores on prior to the collection run, provided
69   // that the duration of the recording is less than or equal to the value of
70   // 'hardwire_cpus_max_duration'.
71   bool hardwire_cpus = true;
72   uint32_t hardwire_cpus_max_duration_in_s = 5;
73
74   // Maximum number of unprocessed profiles we can accumulate in the
75   // destination directory. Once we reach this limit, we continue
76   // to collect, but we just overwrite the most recent profile.
77   uint32_t max_unprocessed_profiles = 10;
78
79   // If set to 1, pass the -g option when invoking 'perf' (requests
80   // stack traces as opposed to flat profile).
81   bool stack_profile = false;
82
83   // For unit testing only: if set to 1, emit info messages on config
84   // file parsing.
85   bool trace_config_read = false;
86
87   // Control collection of various additional profile tags
88   bool collect_cpu_utilization = true;
89   bool collect_charging_state = true;
90   bool collect_booting = true;
91   bool collect_camera_active = false;
92
93   // Sleep for the given number of seconds.
94   virtual void Sleep(size_t seconds) = 0;
95
96   // Should the profiling be stopped immediately?
97   virtual bool ShouldStopProfiling() {
98     return false;
99   }
100
101   // Is profiling enabled?
102   virtual bool IsProfilingEnabled() const = 0;
103 };
104
105 #endif  // SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_