blob: 4ab20520ad554967f41b4b9018dd6c8a42b3f6bb [file] [log] [blame]
Calin Juravle138dbff2016-06-28 19:36:58 +01001/*
2 * Copyright (C) 2016 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 * * See the License for the specific language governing permissions and
10 * limitations under the License.
11 */
12
13#ifndef ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_
14#define ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_
15
16#include <string>
17#include <ostream>
18
19namespace art {
20
21struct ProfileSaverOptions {
22 public:
23 static constexpr uint32_t kMinSavePeriodMs = 20 * 1000; // 20 seconds
Mathieu Chartiercbb7cee2017-03-14 15:23:03 -070024 static constexpr uint32_t kSaveResolvedClassesDelayMs = 5 * 1000; // 5 seconds
Calin Juravle138dbff2016-06-28 19:36:58 +010025 // Minimum number of JIT samples during launch to include a method into the profile.
26 static constexpr uint32_t kStartupMethodSamples = 1;
27 static constexpr uint32_t kMinMethodsToSave = 10;
28 static constexpr uint32_t kMinClassesToSave = 10;
29 static constexpr uint32_t kMinNotificationBeforeWake = 10;
30 static constexpr uint32_t kMaxNotificationBeforeWake = 50;
31
32 ProfileSaverOptions() :
33 enabled_(false),
34 min_save_period_ms_(kMinSavePeriodMs),
35 save_resolved_classes_delay_ms_(kSaveResolvedClassesDelayMs),
36 startup_method_samples_(kStartupMethodSamples),
37 min_methods_to_save_(kMinMethodsToSave),
38 min_classes_to_save_(kMinClassesToSave),
39 min_notification_before_wake_(kMinNotificationBeforeWake),
40 max_notification_before_wake_(kMaxNotificationBeforeWake) {}
41
42 ProfileSaverOptions(
43 bool enabled,
44 uint32_t min_save_period_ms,
45 uint32_t save_resolved_classes_delay_ms,
46 uint32_t startup_method_samples,
47 uint32_t min_methods_to_save,
48 uint32_t min_classes_to_save,
49 uint32_t min_notification_before_wake,
50 uint32_t max_notification_before_wake):
51 enabled_(enabled),
52 min_save_period_ms_(min_save_period_ms),
53 save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms),
54 startup_method_samples_(startup_method_samples),
55 min_methods_to_save_(min_methods_to_save),
56 min_classes_to_save_(min_classes_to_save),
57 min_notification_before_wake_(min_notification_before_wake),
58 max_notification_before_wake_(max_notification_before_wake) {}
59
60 bool IsEnabled() const {
61 return enabled_;
62 }
63 void SetEnabled(bool enabled) {
64 enabled_ = enabled;
65 }
66
67 uint32_t GetMinSavePeriodMs() const {
68 return min_save_period_ms_;
69 }
70 uint32_t GetSaveResolvedClassesDelayMs() const {
71 return save_resolved_classes_delay_ms_;
72 }
73 uint32_t GetStartupMethodSamples() const {
74 return startup_method_samples_;
75 }
76 uint32_t GetMinMethodsToSave() const {
77 return min_methods_to_save_;
78 }
79 uint32_t GetMinClassesToSave() const {
80 return min_classes_to_save_;
81 }
82 uint32_t GetMinNotificationBeforeWake() const {
83 return min_notification_before_wake_;
84 }
85 uint32_t GetMaxNotificationBeforeWake() const {
86 return max_notification_before_wake_;
87 }
88
89 friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) {
90 os << "enabled_" << pso.enabled_
91 << ", min_save_period_ms_" << pso.min_save_period_ms_
92 << ", save_resolved_classes_delay_ms_" << pso.save_resolved_classes_delay_ms_
93 << ", startup_method_samples_" << pso.startup_method_samples_
94 << ", min_methods_to_save_" << pso.min_methods_to_save_
95 << ", min_classes_to_save_" << pso.min_classes_to_save_
96 << ", min_notification_before_wake_" << pso.min_notification_before_wake_
97 << ", max_notification_before_wake_" << pso.max_notification_before_wake_;
98 return os;
99 }
100
101 bool enabled_;
102 uint32_t min_save_period_ms_;
103 uint32_t save_resolved_classes_delay_ms_;
104 uint32_t startup_method_samples_;
105 uint32_t min_methods_to_save_;
106 uint32_t min_classes_to_save_;
107 uint32_t min_notification_before_wake_;
108 uint32_t max_notification_before_wake_;
109};
110
111} // namespace art
112
113#endif // ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_