blob: 07aeb66eb6439e00f304d78ce1fe414d9bb6933d [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:
Calin Juravle806843a2017-05-01 15:14:44 -070023 static constexpr uint32_t kMinSavePeriodMs = 40 * 1000; // 40 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),
Calin Juravle9545f6d2017-03-16 19:05:09 -070040 max_notification_before_wake_(kMaxNotificationBeforeWake),
41 profile_path_("") {}
Calin Juravle138dbff2016-06-28 19:36:58 +010042
43 ProfileSaverOptions(
44 bool enabled,
45 uint32_t min_save_period_ms,
46 uint32_t save_resolved_classes_delay_ms,
47 uint32_t startup_method_samples,
48 uint32_t min_methods_to_save,
49 uint32_t min_classes_to_save,
50 uint32_t min_notification_before_wake,
Calin Juravle9545f6d2017-03-16 19:05:09 -070051 uint32_t max_notification_before_wake,
52 const std::string& profile_path):
Calin Juravle138dbff2016-06-28 19:36:58 +010053 enabled_(enabled),
54 min_save_period_ms_(min_save_period_ms),
55 save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms),
56 startup_method_samples_(startup_method_samples),
57 min_methods_to_save_(min_methods_to_save),
58 min_classes_to_save_(min_classes_to_save),
59 min_notification_before_wake_(min_notification_before_wake),
Calin Juravle9545f6d2017-03-16 19:05:09 -070060 max_notification_before_wake_(max_notification_before_wake),
61 profile_path_(profile_path) {}
Calin Juravle138dbff2016-06-28 19:36:58 +010062
63 bool IsEnabled() const {
64 return enabled_;
65 }
66 void SetEnabled(bool enabled) {
67 enabled_ = enabled;
68 }
69
70 uint32_t GetMinSavePeriodMs() const {
71 return min_save_period_ms_;
72 }
73 uint32_t GetSaveResolvedClassesDelayMs() const {
74 return save_resolved_classes_delay_ms_;
75 }
76 uint32_t GetStartupMethodSamples() const {
77 return startup_method_samples_;
78 }
79 uint32_t GetMinMethodsToSave() const {
80 return min_methods_to_save_;
81 }
82 uint32_t GetMinClassesToSave() const {
83 return min_classes_to_save_;
84 }
85 uint32_t GetMinNotificationBeforeWake() const {
86 return min_notification_before_wake_;
87 }
88 uint32_t GetMaxNotificationBeforeWake() const {
89 return max_notification_before_wake_;
90 }
Calin Juravle9545f6d2017-03-16 19:05:09 -070091 std::string GetProfilePath() const {
92 return profile_path_;
93 }
Calin Juravle138dbff2016-06-28 19:36:58 +010094
95 friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) {
96 os << "enabled_" << pso.enabled_
97 << ", min_save_period_ms_" << pso.min_save_period_ms_
98 << ", save_resolved_classes_delay_ms_" << pso.save_resolved_classes_delay_ms_
99 << ", startup_method_samples_" << pso.startup_method_samples_
100 << ", min_methods_to_save_" << pso.min_methods_to_save_
101 << ", min_classes_to_save_" << pso.min_classes_to_save_
102 << ", min_notification_before_wake_" << pso.min_notification_before_wake_
103 << ", max_notification_before_wake_" << pso.max_notification_before_wake_;
104 return os;
105 }
106
107 bool enabled_;
108 uint32_t min_save_period_ms_;
109 uint32_t save_resolved_classes_delay_ms_;
110 uint32_t startup_method_samples_;
111 uint32_t min_methods_to_save_;
112 uint32_t min_classes_to_save_;
113 uint32_t min_notification_before_wake_;
114 uint32_t max_notification_before_wake_;
Calin Juravle9545f6d2017-03-16 19:05:09 -0700115 std::string profile_path_;
Calin Juravle138dbff2016-06-28 19:36:58 +0100116};
117
118} // namespace art
119
120#endif // ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_