OSDN Git Service

libperfmgr: change to use Value directly in config
[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. A value of 0 means perf default. sampling_frequency
56   // takes priority.
57   uint32_t sampling_period = 0;
58   // Desired sampling frequency (passed to perf -f option). A value of 0
59   // means using sampling_period or default.
60   uint32_t sampling_frequency = 0;
61   // Length of time to collect samples (number of seconds for 'perf
62   // record -a' run).
63   uint32_t sample_duration_in_s = 2;
64
65   // If this parameter is non-zero it will cause perfprofd to
66   // exit immediately if the build type is not userdebug or eng.
67   // Currently defaults to 1 (true).
68   bool only_debug_build = true;
69
70   // If the "mpdecision" service is running at the point we are ready
71   // to kick off a profiling run, then temporarily disable the service
72   // and hard-wire all cores on prior to the collection run, provided
73   // that the duration of the recording is less than or equal to the value of
74   // 'hardwire_cpus_max_duration'.
75   bool hardwire_cpus = true;
76   uint32_t hardwire_cpus_max_duration_in_s = 5;
77
78   // Maximum number of unprocessed profiles we can accumulate in the
79   // destination directory. Once we reach this limit, we continue
80   // to collect, but we just overwrite the most recent profile.
81   uint32_t max_unprocessed_profiles = 10;
82
83   // If set to 1, pass the -g option when invoking 'perf' (requests
84   // stack traces as opposed to flat profile).
85   bool stack_profile = false;
86
87   // For unit testing only: if set to 1, emit info messages on config
88   // file parsing.
89   bool trace_config_read = false;
90
91   // Control collection of various additional profile tags
92   bool collect_cpu_utilization = true;
93   bool collect_charging_state = true;
94   bool collect_booting = true;
95   bool collect_camera_active = false;
96
97   // If true, use an ELF symbolizer to on-device symbolize.
98   bool use_elf_symbolizer = true;
99
100   // If true, use libz to compress the output proto.
101   bool compress = true;
102
103   // If true, send the proto to dropbox instead to a file.
104   bool send_to_dropbox = false;
105
106   // Sleep for the given number of seconds.
107   virtual void Sleep(size_t seconds) = 0;
108
109   // Should the profiling be stopped immediately?
110   virtual bool ShouldStopProfiling() {
111     return false;
112   }
113
114   // Is profiling enabled?
115   virtual bool IsProfilingEnabled() const = 0;
116 };
117
118 #endif  // SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_