< prev index next >
test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitor.c
Print this page
@@ -359,11 +359,11 @@
native_frames[i].signature = signature;
native_frames[i].line_number = line_number;
}
}
-static jint checkAnd(JNIEnv *env, jobjectArray frames, int live, int recent,
+static jint check_and(JNIEnv *env, jobjectArray frames, int live, int recent,
int frequent) {
jobject loader = NULL;
if (frames == NULL) {
return 0;
@@ -396,11 +396,11 @@
}
return result;
}
-static jint checkOr(JNIEnv *env, jobjectArray frames, int live, int recent,
+static jint check_or(JNIEnv *env, jobjectArray frames, int live, int recent,
int frequent) {
jobject loader = NULL;
if (frames == NULL) {
return 0;
@@ -434,11 +434,11 @@
return result;
}
static jint checkAll(JNIEnv *env, jobjectArray frames) {
- return checkAnd(env, frames, 1, 1, 1);
+ return check_and(env, frames, 1, 1, 1);
}
static jint checkNone(JNIEnv *env, jobjectArray frames) {
jobject loader = NULL;
@@ -532,19 +532,19 @@
return PASSED;
}
JNIEXPORT jint JNICALL
Java_MyPackage_HeapMonitorRecentTest_checkLiveOrRecentFrames(JNIEnv *env, jclass cls, jobjectArray frames) {
- if (checkOr(env, frames, 1, 1, 0)) {
+ if (check_or(env, frames, 1, 1, 0)) {
return FAILED;
}
return PASSED;
}
JNIEXPORT jint JNICALL
Java_MyPackage_HeapMonitorRecentTest_checkLiveAndRecentFrames(JNIEnv *env, jclass cls, jobjectArray frames) {
- if (checkAnd(env, frames, 1, 1, 0)) {
+ if (check_and(env, frames, 1, 1, 0)) {
return FAILED;
}
return PASSED;
}
@@ -563,11 +563,11 @@
return PASSED;
}
JNIEXPORT jint JNICALL
Java_MyPackage_HeapMonitorFrequentTest_checkFrequentFrames(JNIEnv *env, jclass cls, jobjectArray frames) {
- if (checkAnd(env, frames, 0, 0, 1)) {
+ if (check_and(env, frames, 0, 0, 1)) {
return PASSED;
}
return FAILED;
}
@@ -668,26 +668,35 @@
int percent_error) {
jvmtiHeapSamplingStats stats;
check_error((*jvmti)->GetHeapSamplingStats(jvmti, &stats),
"Heap Sampling Statistics");
- fprintf(stderr, "Statistics show:\n");
- fprintf(stderr, "\tCollected samples: %ld\n\tGarbage collected samples: %ld\n",
- stats.sample_count, stats.garbage_collected_samples);
- fprintf(stderr, "\tSample rate accumulated: %ld\n\tSample Rate Count: %ld\n",
- stats.sample_rate_accumulation, stats.sample_rate_count);
- fprintf(stderr, "\tStack depth accumulation: %ld\n",
- stats.stack_depth_accumulation);
-
- fprintf(stderr, "Expected is %d\n", expected);
double diff_ratio = (stats.sample_count - expected);
diff_ratio = (diff_ratio < 0) ? -diff_ratio : diff_ratio;
diff_ratio /= expected;
- fprintf(stderr, "Diff ratio is %f\n", diff_ratio);
-
return diff_ratio * 100 > percent_error;
}
+JNIEXPORT void JNICALL
+Java_MyPackage_HeapMonitorStatRateTest_enableSampling(JNIEnv *env, jclass cls, jint rate) {
+ enable_sampling_with_rate(rate);
+}
+
+JNIEXPORT void JNICALL
+Java_MyPackage_HeapMonitorStatRateTest_disableSampling(JNIEnv *env, jclass cls) {
+ disable_sampling();
+}
+
+JNIEXPORT jdouble JNICALL
+Java_MyPackage_HeapMonitorStatRateTest_getAverageRate(JNIEnv *env, jclass cls) {
+ jvmtiHeapSamplingStats stats;
+ check_error((*jvmti)->GetHeapSamplingStats(jvmti, &stats),
+ "Heap Sampling Statistics");
+ (int) stats.sample_rate_accumulation, (int) stats.sample_rate_count);
+
+ return ((double) stats.sample_rate_accumulation) / stats.sample_rate_count;
+}
+
#ifdef __cplusplus
}
#endif
< prev index next >