OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/pacing/alr_detector.h" | 11 #include "webrtc/modules/pacing/alr_detector.h" |
12 | 12 |
13 #include <map> | |
13 #include <string> | 14 #include <string> |
14 | 15 |
15 #include "webrtc/rtc_base/checks.h" | 16 #include "webrtc/rtc_base/checks.h" |
16 #include "webrtc/rtc_base/format_macros.h" | 17 #include "webrtc/rtc_base/format_macros.h" |
17 #include "webrtc/rtc_base/logging.h" | 18 #include "webrtc/rtc_base/logging.h" |
18 #include "webrtc/rtc_base/timeutils.h" | 19 #include "webrtc/rtc_base/timeutils.h" |
19 #include "webrtc/system_wrappers/include/field_trial.h" | 20 #include "webrtc/system_wrappers/include/field_trial.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime() | 75 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime() |
75 const { | 76 const { |
76 return alr_started_time_ms_; | 77 return alr_started_time_ms_; |
77 } | 78 } |
78 | 79 |
79 rtc::Optional<AlrDetector::AlrExperimentSettings> | 80 rtc::Optional<AlrDetector::AlrExperimentSettings> |
80 AlrDetector::ParseAlrSettingsFromFieldTrial(const char* experiment_name) { | 81 AlrDetector::ParseAlrSettingsFromFieldTrial(const char* experiment_name) { |
81 rtc::Optional<AlrExperimentSettings> ret; | 82 rtc::Optional<AlrExperimentSettings> ret; |
82 std::string group_name = field_trial::FindFullName(experiment_name); | 83 std::string group_name = field_trial::FindFullName(experiment_name); |
83 | 84 |
85 static std::map<const char*, | |
86 rtc::Optional<AlrDetector::AlrExperimentSettings>> | |
87 computed_results; | |
88 | |
89 auto it = computed_results.find(experiment_name); | |
90 if (it != computed_results.end()) { | |
91 return it->second; | |
92 } | |
93 computed_results[experiment_name] = ret; | |
sprang_webrtc
2017/08/24 09:13:16
Looks like you can drop this insertion?
ilnik
2017/08/25 12:35:07
No. Currently the function may exit below if it fa
| |
94 | |
84 const std::string kIgnoredSuffix = "_Dogfood"; | 95 const std::string kIgnoredSuffix = "_Dogfood"; |
85 if (group_name.rfind(kIgnoredSuffix) == | 96 if (group_name.rfind(kIgnoredSuffix) == |
86 group_name.length() - kIgnoredSuffix.length()) { | 97 group_name.length() - kIgnoredSuffix.length()) { |
87 group_name.resize(group_name.length() - kIgnoredSuffix.length()); | 98 group_name.resize(group_name.length() - kIgnoredSuffix.length()); |
88 } | 99 } |
89 | 100 |
90 if (group_name.empty()) | 101 if (group_name.empty()) |
91 return ret; | 102 return ret; |
92 | 103 |
93 AlrExperimentSettings settings; | 104 AlrExperimentSettings settings; |
94 if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d", | 105 if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d", |
95 &settings.pacing_factor, &settings.max_paced_queue_time, | 106 &settings.pacing_factor, &settings.max_paced_queue_time, |
96 &settings.alr_bandwidth_usage_percent, | 107 &settings.alr_bandwidth_usage_percent, |
97 &settings.alr_start_budget_level_percent, | 108 &settings.alr_start_budget_level_percent, |
98 &settings.alr_stop_budget_level_percent) == 5) { | 109 &settings.alr_stop_budget_level_percent, |
110 &settings.group_id) == 6) { | |
99 ret.emplace(settings); | 111 ret.emplace(settings); |
100 LOG(LS_INFO) << "Using ALR experiment settings: " | 112 LOG(LS_INFO) << "Using ALR experiment settings: " |
101 "pacing factor: " | 113 "pacing factor: " |
102 << settings.pacing_factor << ", max pacer queue length: " | 114 << settings.pacing_factor << ", max pacer queue length: " |
103 << settings.max_paced_queue_time | 115 << settings.max_paced_queue_time |
104 << ", ALR start bandwidth usage percent: " | 116 << ", ALR start bandwidth usage percent: " |
105 << settings.alr_bandwidth_usage_percent | 117 << settings.alr_bandwidth_usage_percent |
106 << ", ALR end budget level percent: " | 118 << ", ALR end budget level percent: " |
107 << settings.alr_start_budget_level_percent | 119 << settings.alr_start_budget_level_percent |
108 << ", ALR end budget level percent: " | 120 << ", ALR end budget level percent: " |
109 << settings.alr_stop_budget_level_percent; | 121 << settings.alr_stop_budget_level_percent |
122 << ", ALR experiment group ID: " << settings.group_id; | |
110 } else { | 123 } else { |
111 LOG(LS_INFO) << "Failed to parse ALR experiment: " << experiment_name; | 124 LOG(LS_INFO) << "Failed to parse ALR experiment: " << experiment_name; |
112 } | 125 } |
113 | 126 |
127 computed_results[experiment_name] = ret; | |
114 return ret; | 128 return ret; |
115 } | 129 } |
116 | 130 |
117 } // namespace webrtc | 131 } // namespace webrtc |
OLD | NEW |