Add property to disable sampling profiler.
This is to enable power measurements to be performed without
the profiler running. The default is off (no profiler).
To enable the profiler:
adb shell setprop dalvik.vm.profiler 1
Change-Id: I983f2ffcf6c2c7bb8e29f0610fe259f3d56a4b1d
diff --git a/runtime/profiler.cc b/runtime/profiler.cc
index 0e73812..365c9c3 100644
--- a/runtime/profiler.cc
+++ b/runtime/profiler.cc
@@ -36,6 +36,11 @@
#include "ScopedLocalRef.h"
#include "thread.h"
#include "thread_list.h"
+
+#ifdef HAVE_ANDROID_OS
+#include "cutils/properties.h"
+#endif
+
#if !defined(ART_USE_PORTABLE_COMPILER)
#include "entrypoints/quick/quick_entrypoints.h"
#endif
@@ -259,6 +264,17 @@
}
}
+ // Only on target...
+#ifdef HAVE_ANDROID_OS
+ // Switch off profiler if the dalvik.vm.profiler property has value 0.
+ char buf[PROP_VALUE_MAX];
+ property_get("dalvik.vm.profiler", buf, "0");
+ if (strcmp(buf, "0") == 0) {
+ LOG(INFO) << "Profiler disabled. To enable setprop dalvik.vm.profiler 1";
+ return;
+ }
+#endif
+
LOG(INFO) << "Starting profile with period " << period << "s, duration " << duration <<
"s, interval " << interval_us << "us. Profile file " << profile_file_name;