3 * Copyright 2015, The Android Open Source Project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_
19 #define SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_
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
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;
41 // The pid of the process to profile. May be negative, in which case
42 // the whole system will be profiled.
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";
53 // Desired sampling period (passed to perf -c option). Small
54 // sampling periods can perturb the collected profiles, so enforce
56 uint32_t sampling_period = 5000;
57 // Length of time to collect samples (number of seconds for 'perf
59 uint32_t sample_duration_in_s = 2;
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;
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;
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;
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;
83 // For unit testing only: if set to 1, emit info messages on config
85 bool trace_config_read = false;
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;
93 // Sleep for the given number of seconds.
94 virtual void Sleep(size_t seconds) = 0;
96 // Should the profiling be stopped immediately?
97 virtual bool ShouldStopProfiling() {
101 // Is profiling enabled?
102 virtual bool IsProfilingEnabled() const = 0;
105 #endif // SYSTEM_EXTRAS_PERFPROFD_CONFIG_H_