blob: 08e32cccbc20d038d674d68fbbdc365a23c630b5 [file] [log] [blame]
Calin Juravlec1b643c2014-05-30 23:44:11 +01001/*
2 * Copyright (C) 2014 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#ifndef ART_RUNTIME_PROFILER_OPTIONS_H_
18#define ART_RUNTIME_PROFILER_OPTIONS_H_
19
20#include <string>
21#include <ostream>
22
23namespace art {
24
25class ProfilerOptions {
26 public:
27 static constexpr bool kDefaultEnabled = false;
28 static constexpr uint32_t kDefaultPeriodS = 10;
29 static constexpr uint32_t kDefaultDurationS = 20;
30 static constexpr uint32_t kDefaultIntervalUs = 500;
31 static constexpr double kDefaultBackoffCoefficient = 2.0;
32 static constexpr bool kDefaultStartImmediately = false;
33 static constexpr double kDefaultTopKThreshold = 90.0;
34 static constexpr double kDefaultChangeInTopKThreshold = 10.0;
35
36 ProfilerOptions() :
37 enabled_(kDefaultEnabled),
38 period_s_(kDefaultPeriodS),
39 duration_s_(kDefaultDurationS),
40 interval_us_(kDefaultIntervalUs),
41 backoff_coefficient_(kDefaultBackoffCoefficient),
42 start_immediately_(kDefaultStartImmediately),
43 top_k_threshold_(kDefaultTopKThreshold),
44 top_k_change_threshold_(kDefaultChangeInTopKThreshold) {}
45
46 ProfilerOptions(bool enabled,
47 uint32_t period_s,
48 uint32_t duration_s,
49 uint32_t interval_us,
50 double backoff_coefficient,
51 bool start_immediately,
52 double top_k_threshold,
53 double top_k_change_threshold):
54 enabled_(enabled),
55 period_s_(period_s),
56 duration_s_(duration_s),
57 interval_us_(interval_us),
58 backoff_coefficient_(backoff_coefficient),
59 start_immediately_(start_immediately),
60 top_k_threshold_(top_k_threshold),
61 top_k_change_threshold_(top_k_change_threshold) {}
62
63 bool IsEnabled() const {
64 return enabled_;
65 }
66
67 uint32_t GetPeriodS() const {
68 return period_s_;
69 }
70
71 uint32_t GetDurationS() const {
72 return duration_s_;
73 }
74
75 uint32_t GetIntervalUs() const {
76 return interval_us_;
77 }
78
79 double GetBackoffCoefficient() const {
80 return backoff_coefficient_;
81 }
82
83 bool GetStartImmediately() const {
84 return start_immediately_;
85 }
86
87 double GetTopKThreshold() const {
88 return top_k_threshold_;
89 }
90
91 double GetTopKChangeThreshold() const {
92 return top_k_change_threshold_;
93 }
94
95 private:
96 friend std::ostream & operator<<(std::ostream &os, const ProfilerOptions& po) {
97 os << "enabled=" << po.enabled_
98 << ", period_s=" << po.period_s_
99 << ", duration_s=" << po.duration_s_
100 << ", interval_us=" << po.interval_us_
101 << ", backoff_coefficient=" << po.backoff_coefficient_
102 << ", start_immediately=" << po.start_immediately_
103 << ", top_k_threshold=" << po.top_k_threshold_
104 << ", top_k_change_threshold=" << po.top_k_change_threshold_;
105 return os;
106 }
107
108 friend class ParsedOptions;
109
110 // Whether or not the applications should be profiled.
111 bool enabled_;
112 // Generate profile every n seconds.
113 uint32_t period_s_;
114 // Run profile for n seconds.
115 uint32_t duration_s_;
116 // Microseconds between samples.
117 uint32_t interval_us_;
118 // Coefficient to exponential backoff.
119 double backoff_coefficient_;
120 // Whether the profile should start upon app startup or be delayed by some random offset.
121 bool start_immediately_;
122 // Top K% of samples that are considered relevant when deciding if the app should be recompiled.
123 double top_k_threshold_;
124 // How much the top K% samples needs to change in order for the app to be recompiled.
125 double top_k_change_threshold_;
126};
127
128} // namespace art
129
130
131#endif // ART_RUNTIME_PROFILER_OPTIONS_H_