MCPcopy Create free account
hub / github.com/android/ndk-samples / DumpProfileDataIfNeeded

Function DumpProfileDataIfNeeded

orderfile/app/src/main/cpp/orderfile.cpp:17–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#endif
16
17void DumpProfileDataIfNeeded(const char* temp_dir) {
18#ifdef GENERATE_PROFILES
19 char profile_location[PATH_MAX] = {};
20 snprintf(profile_location, sizeof(profile_location), "%s/demo.profraw",
21 temp_dir);
22 if (__llvm_profile_set_filename(profile_location) == -1) {
23 __android_log_print(ANDROID_LOG_ERROR, kLogTag,
24 "__llvm_profile_set_filename(\"%s\") failed: %s",
25 profile_location, strerror(errno));
26 return;
27 }
28
29 if (__llvm_profile_initialize_file() == -1) {
30 __android_log_print(ANDROID_LOG_ERROR, kLogTag,
31 "__llvm_profile_initialize_file failed: %s",
32 strerror(errno));
33 return;
34 }
35
36 if (__llvm_profile_dump() == -1) {
37 __android_log_print(ANDROID_LOG_ERROR, kLogTag,
38 "__llvm_profile_dump() failed: %s", strerror(errno));
39 return;
40 }
41 __android_log_print(ANDROID_LOG_DEBUG, kLogTag, "Wrote profile data to %s",
42 profile_location);
43#else
44 (void)temp_dir; // To avoid unused-parameter warning
45 __android_log_print(ANDROID_LOG_DEBUG, kLogTag,
46 "Did not write profile data because the app was not "
47 "built for profile generation");
48#endif
49}
50
51void RunWorkload(JNIEnv* env, jobject /* this */, jstring temp_dir) {
52 DumpProfileDataIfNeeded(env->GetStringUTFChars(temp_dir, 0));

Callers 1

RunWorkloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected