summaryrefslogtreecommitdiffstats
path: root/runtime/utils.cc
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-05-23 17:33:29 +0100
committerCalin Juravle <calin@google.com>2014-06-06 11:53:28 +0100
commitbb0b53f58f11c628f077603b56077dfed1a18f11 (patch)
tree013482db95e8f2dcb7c7be85fc8f35df2c7f1361 /runtime/utils.cc
parente4283be97047a26d3476acd3863dcc386498be17 (diff)
downloadandroid_art-bb0b53f58f11c628f077603b56077dfed1a18f11.tar.gz
android_art-bb0b53f58f11c628f077603b56077dfed1a18f11.tar.bz2
android_art-bb0b53f58f11c628f077603b56077dfed1a18f11.zip
Clean up the sampling profiler
- rename variables/fields names to match the code style (use _underscore_names_) - extract common property parsing in utils.cc - fail to load profile file if any line is malformed - added ProfileFile to manage the profile data generate in the previous runs (replaces ProfileHelper and nests ProfileData) Bug: 12877748 Change-Id: Ie7bda30bfdeb7e78534c986615b0649eac12a97b
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r--runtime/utils.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc
index f562252823..05ff5ffbdf 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1302,4 +1302,23 @@ bool Exec(std::vector<std::string>& arg_vector, std::string* error_msg) {
return true;
}
+double GetDoubleProperty(const char* property, double min_value, double max_value, double default_value) {
+#ifndef HAVE_ANDROID_OS
+ return default_value;
+#else
+ char buf[PROP_VALUE_MAX];
+ char* endptr;
+
+ property_get(property, buf, "");
+ double value = strtod(buf, &endptr);
+
+ // Return the defalt value if the string is invalid or the value is outside the given range
+ if ((value == 0 && endptr == buf) // Invalid string
+ || (value < min_value) || (value > max_value)) { // Out of range value
+ return default_value;
+ }
+ return value;
+#endif
+}
+
} // namespace art