结构优化

This commit is contained in:
2026-07-30 18:09:03 +08:00
parent 9271599723
commit 13ca0f3141
107 changed files with 3749 additions and 2424 deletions
+13 -8
View File
@@ -2,12 +2,13 @@
#include <QElapsedTimer>
#include <QEventLoop>
#include <QThread>
#include <gtest/gtest.h>
#include <cmath>
#include <memory>
#include <thread>
#include "../Renderive/Axis/Axis.h"
#include "../Renderive/Axis/Frequency_Axis.h"
#include "../Renderive/architecture/Plot.h"
#include "../Renderive/plot/Latency_Eager_Plot.h"
#include "../Renderive/plottable/Spectrum.h"
namespace {
std::vector<double> make_spectrum_data(int size, int frame) {
@@ -25,7 +26,7 @@ void process_events(int ms) {
}
}
void stress_remove_local_cache_renderable() {
renderive::Plot plot;
renderive::Latency_Eager_Plot plot;
plot.init();
plot.resize(640, 360);
auto data = plot.create_renderable_node(plot.get_root_renderable(), "Data_Renderable");
@@ -45,7 +46,7 @@ void stress_remove_local_cache_renderable() {
}
void stress_plot_destroy_with_pending_tasks() {
for (int round = 0; round < 32; ++round) {
auto plot = std::make_unique<renderive::Plot>();
auto plot = std::make_unique<renderive::Latency_Eager_Plot>();
plot->init();
plot->resize(480, 240);
auto data = plot->create_renderable_node(plot->get_root_renderable(), "Data_Renderable");
@@ -69,7 +70,7 @@ void stress_plot_destroy_with_pending_tasks() {
void stress_release_renderable_after_plot_destroy() {
std::shared_ptr<renderive::Renderable> survivor;
{
renderive::Plot plot;
renderive::Latency_Eager_Plot plot;
plot.init();
survivor = plot.create_renderable_node(plot.get_root_renderable(), "Survivor");
}
@@ -79,12 +80,16 @@ void stress_release_renderable_after_plot_destroy() {
release_thread.join();
}
}
int main(int argc, char** argv) {
QApplication app(argc, argv);
renderive::start_render_scheduler();
TEST(Renderable_Lifecycle_Stress, HandlesRemovalDestroyAndLateRelease) {
stress_remove_local_cache_renderable();
stress_plot_destroy_with_pending_tasks();
stress_release_renderable_after_plot_destroy();
process_events(250);
return 0;
}
int main(int argc, char** argv) {
qputenv("QT_QPA_PLATFORM", "offscreen");
QApplication app(argc, argv);
testing::InitGoogleTest(&argc, argv);
renderive::start_render_scheduler();
return RUN_ALL_TESTS();
}