jfjoch_viewer: Auto foreground comes from integer histogram - it is much faster compared to previous implementation
This commit is contained in:
@@ -29,61 +29,58 @@ TEST_CASE("SetAverage") {
|
||||
CHECK(p.GetPlots()[0].y[99] == 0.0);
|
||||
}
|
||||
|
||||
TEST_CASE("FloatHistogram") {
|
||||
FloatHistogram h(100, 100.0, 200.0);
|
||||
h.Add(150.5);
|
||||
h.Add(100.2);
|
||||
h.Add(100.9999);
|
||||
h.Add(100.0);
|
||||
h.Add(100.00001);
|
||||
h.Add(101.0);
|
||||
h.Add(200.0);
|
||||
TEST_CASE("Histogram") {
|
||||
Histogram h(200);
|
||||
h.Add(150);
|
||||
h.Add(100);
|
||||
h.Add(100);
|
||||
h.Add(100);
|
||||
h.Add(100);
|
||||
h.Add(101);
|
||||
h.Add(199);
|
||||
h.Add(200); // Outside or range
|
||||
h.Add(-1); // Outside of range
|
||||
|
||||
auto p = h.GetPlot();
|
||||
REQUIRE(p.GetPlots().size() == 1);
|
||||
REQUIRE(p.GetPlots()[0].x.size() == 100);
|
||||
REQUIRE(p.GetPlots()[0].y.size() == 100);
|
||||
|
||||
CHECK(p.GetPlots()[0].x[0] == 100.5);
|
||||
CHECK(p.GetPlots()[0].x[34] == 134.5);
|
||||
CHECK(p.GetPlots()[0].x[99] == 199.5);
|
||||
|
||||
CHECK(p.GetPlots()[0].y[0] == 4.0);
|
||||
CHECK(p.GetPlots()[0].y[1] == 1.0);
|
||||
CHECK(p.GetPlots()[0].y[50] == 1.0);
|
||||
CHECK(p.GetPlots()[0].y[99] == 0.0);
|
||||
CHECK(h.GetTotalCount() == 7);
|
||||
auto p = h.GetCount();
|
||||
REQUIRE(p.size() == 200);
|
||||
CHECK(p[100] == 4);
|
||||
CHECK(p[150] == 1);
|
||||
CHECK(p[199] == 1);
|
||||
CHECK(p[101] == 1);
|
||||
CHECK(p[55] == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("FloatHistogram_Percentile") {
|
||||
FloatHistogram h(111, 89.5, 200.5);
|
||||
TEST_CASE("Histogram_Percentile") {
|
||||
Histogram h(500);
|
||||
for (int i = 0; i < 8; i++)
|
||||
h.Add(100.0f);
|
||||
h.Add(150.0f);
|
||||
h.Add(200.0f);
|
||||
|
||||
CHECK(h.Percentile(0.0f).value_or(-1) == Catch::Approx(100.0f));
|
||||
CHECK(h.Percentile(30.0f).value_or(-1) == Catch::Approx(100.0f));
|
||||
CHECK(h.Percentile(50.0f).value_or(-1) == Catch::Approx(100.0f));
|
||||
CHECK(h.Percentile(80.0f).value_or(-1) == Catch::Approx(100.0f));
|
||||
CHECK(h.Percentile(90.0f).value_or(-1) == Catch::Approx(150.0f));
|
||||
CHECK(h.Percentile(100.0f).value_or(-1) == Catch::Approx(200.0f));
|
||||
CHECK(h.Percentile(0.0f).value_or(-1) == 100);
|
||||
CHECK(h.Percentile(30.0f).value_or(-1) == 100);
|
||||
CHECK(h.Percentile(50.0f).value_or(-1) == 100);
|
||||
CHECK(h.Percentile(80.0f).value_or(-1) == 100);
|
||||
CHECK(h.Percentile(90.0f).value_or(-1) == 150);
|
||||
CHECK(h.Percentile(100.0f).value_or(-1) == 200);
|
||||
|
||||
CHECK(h.TotalCount() == 10);
|
||||
CHECK(h.GetTotalCount() == 10);
|
||||
}
|
||||
|
||||
TEST_CASE("FloatHistogram_Clear") {
|
||||
FloatHistogram h(111, 89.5, 200.5);
|
||||
TEST_CASE("Histogram_Clear") {
|
||||
Histogram h(300);
|
||||
for (int i = 0; i < 8; i++)
|
||||
h.Add(100.0f);
|
||||
h.Add(150.0f);
|
||||
h.Add(200.0f);
|
||||
h.Add(100);
|
||||
h.Add(150);
|
||||
h.Add(200);
|
||||
|
||||
CHECK(h.TotalCount() == 10);
|
||||
CHECK(h.GetTotalCount() == 10);
|
||||
|
||||
h.clear();
|
||||
|
||||
CHECK(h.TotalCount() == 0);
|
||||
CHECK(h.GetTotalCount() == 0);
|
||||
|
||||
h.Add(200.0f);
|
||||
CHECK(h.TotalCount() == 1);
|
||||
CHECK(h.GetTotalCount() == 1);
|
||||
}
|
||||
Reference in New Issue
Block a user