Faster Preview View (#15884)

Co-authored-by: Kris Austin <kris.austin@gmail.com>
This commit is contained in:
Ian Bassi
2026-10-02 14:45:58 -03:00
committed by GitHub
co-authored by Kris Austin
parent 4ffba13210
commit 70bc02467b
37 changed files with 1740 additions and 290 deletions
+1
View File
@@ -9,6 +9,7 @@ add_executable(${_TEST_NAME}_tests
test_device_manager_integration.cpp
test_web_media_controller.cpp
test_scene_raycaster.cpp
test_scene_benchmark.cpp
test_lazy.cpp
test_prebuild_queue.cpp
test_staged_build.cpp
+2 -1
View File
@@ -238,7 +238,8 @@ TEST_CASE("Native command catalog includes the Help and developer-mode commands"
const Slic3r::GUI::NativeCommand* first = find("help_keyboard_shortcuts");
REQUIRE(first != nullptr);
for (const char* key : {"help_setup_wizard", "help_open_config_folder", "help_troubleshoot", "help_network_test",
"help_tip_of_the_day", "help_check_updates", "help_about", "open_wiki", "open_youtube"}) {
"help_benchmark_3d_scene", "help_tip_of_the_day", "help_check_updates", "help_about", "open_wiki",
"open_youtube"}) {
const Slic3r::GUI::NativeCommand* c = find(key);
REQUIRE(c != nullptr);
CHECK(c->group == first->group);
@@ -0,0 +1,57 @@
#include <catch2/catch_all.hpp>
#include "slic3r/GUI/SceneBenchmark.hpp"
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
using Catch::Matchers::WithinAbs;
using Slic3r::GUI::frame_time_stats;
using Slic3r::GUI::FrameTimeStats;
TEST_CASE("Frame time statistics take percentiles by nearest rank", "[SceneBenchmark]")
{
// 1 to 100 ms in shuffled order: the p-th percentile is the p-th frame time.
std::vector<double> frame_ms(100);
std::iota(frame_ms.begin(), frame_ms.end(), 1.0);
std::shuffle(frame_ms.begin(), frame_ms.end(), std::mt19937(42));
const FrameTimeStats stats = frame_time_stats(frame_ms);
CHECK_THAT(stats.average_ms, WithinAbs(50.5, 1e-9));
CHECK_THAT(stats.fps, WithinAbs(1000.0 / 50.5, 1e-9));
CHECK_THAT(stats.median_ms, WithinAbs(50.0, 1e-9));
CHECK_THAT(stats.p95_ms, WithinAbs(95.0, 1e-9));
CHECK_THAT(stats.p99_ms, WithinAbs(99.0, 1e-9));
CHECK_THAT(stats.max_ms, WithinAbs(100.0, 1e-9));
}
TEST_CASE("Frame time percentiles are measured frame times", "[SceneBenchmark]")
{
// 360 frames, as in a benchmark pass: rank 342 for p95 and rank 357 for p99.
std::vector<double> frame_ms(360);
std::iota(frame_ms.begin(), frame_ms.end(), 1.0);
const FrameTimeStats stats = frame_time_stats(frame_ms);
CHECK_THAT(stats.median_ms, WithinAbs(180.0, 1e-9));
CHECK_THAT(stats.p95_ms, WithinAbs(342.0, 1e-9));
CHECK_THAT(stats.p99_ms, WithinAbs(357.0, 1e-9));
}
TEST_CASE("Frame time statistics of a single frame are that frame", "[SceneBenchmark]")
{
const FrameTimeStats stats = frame_time_stats({ 4.0 });
CHECK_THAT(stats.fps, WithinAbs(250.0, 1e-9));
CHECK_THAT(stats.median_ms, WithinAbs(4.0, 1e-9));
CHECK_THAT(stats.p99_ms, WithinAbs(4.0, 1e-9));
CHECK_THAT(stats.max_ms, WithinAbs(4.0, 1e-9));
}
TEST_CASE("Frame time statistics of no frames are zero", "[SceneBenchmark]")
{
const FrameTimeStats stats = frame_time_stats({});
CHECK_THAT(stats.fps, WithinAbs(0.0, 1e-9));
CHECK_THAT(stats.average_ms, WithinAbs(0.0, 1e-9));
CHECK_THAT(stats.max_ms, WithinAbs(0.0, 1e-9));
}