< prev index next >
test/hotspot/gtest/gc/g1/test_g1Predictions.cpp
Print this page
rev 56997 : [mq]: 8227434-g1-predictions-overflow
*** 24,33 ****
--- 24,35 ----
#include "precompiled.hpp"
#include "gc/g1/g1Predictions.hpp"
#include "unittest.hpp"
+ #include "utilities/ostream.hpp"
+
static const double epsilon = 1e-6;
// Some basic formula tests with confidence = 0.0
TEST_VM(G1Predictions, basic_predictions) {
G1Predictions predictor(0.0);
*** 94,98 ****
--- 96,148 ----
s.add(0.2);
s.add(2.0);
double p4 = predictor.get_new_prediction(&s);
ASSERT_GT(p4, p3) << "Fourth prediction must be greater than third";
}
+
+ // Some tests to verify bounding between [0 .. 1]
+ TEST_VM(G1Predictions, unit_predictions) {
+ G1Predictions predictor(0.5);
+ TruncatedSeq s;
+
+ double p0 = predictor.get_new_unit_prediction(&s);
+ ASSERT_LT(p0, epsilon) << "Initial prediction of empty sequence must be 0.0";
+
+ s.add(100.0);
+ double p1 = predictor.get_new_unit_prediction(&s);
+ ASSERT_NEAR(p1, 1.0, epsilon);
+
+ // Feed the sequence additional positive values to test the high bound.
+ for (int i = 0; i < 3; i++) {
+ s.add(2.0);
+ }
+ ASSERT_NEAR(predictor.get_new_unit_prediction(&s), 1.0, epsilon);
+
+ // Feed the sequence additional large negative value to test the low bound.
+ for (int i = 0; i < 4; i++) {
+ s.add(-200.0);
+ }
+ ASSERT_NEAR(predictor.get_new_unit_prediction(&s), 0.0, epsilon);
+ }
+
+ // Some tests to verify bounding between [0 .. +inf]
+ TEST_VM(G1Predictions, lower_bound_zero_predictions) {
+ G1Predictions predictor(0.5);
+ TruncatedSeq s;
+
+ double p0 = predictor.get_new_lower_zero_bound_prediction(&s);
+ ASSERT_LT(p0, epsilon) << "Initial prediction of empty sequence must be 0.0";
+
+ s.add(100.0);
+ // Feed the sequence additional positive values to see that the high bound is not
+ // bounded by e.g. 1.0
+ for (int i = 0; i < 3; i++) {
+ s.add(2.0);
+ }
+ ASSERT_GT(predictor.get_new_lower_zero_bound_prediction(&s), 1.0);
+
+ // Feed the sequence additional large negative value to test the low bound.
+ for (int i = 0; i < 4; i++) {
+ s.add(-200.0);
+ }
+ ASSERT_NEAR(predictor.get_new_lower_zero_bound_prediction(&s), 0.0, epsilon);
+ }
< prev index next >