Electron crystal simulation computation time measurement
This commit is contained in:
parent
8aec37d1de
commit
592fb437e7
1 changed files with 17 additions and 1 deletions
|
|
@ -19,6 +19,7 @@
|
||||||
#include <psemek/ui/event_interceptor.hpp>
|
#include <psemek/ui/event_interceptor.hpp>
|
||||||
#include <psemek/util/to_string.hpp>
|
#include <psemek/util/to_string.hpp>
|
||||||
#include <psemek/util/recursive.hpp>
|
#include <psemek/util/recursive.hpp>
|
||||||
|
#include <psemek/util/moving_average.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -39,6 +40,8 @@ struct main_scene
|
||||||
float step = 1e-4f;
|
float step = 1e-4f;
|
||||||
float multipole_threshold = 2.f;
|
float multipole_threshold = 2.f;
|
||||||
|
|
||||||
|
std::shared_ptr<ui::label> time_value_label;
|
||||||
|
|
||||||
random::generator rng{random::device{}};
|
random::generator rng{random::device{}};
|
||||||
|
|
||||||
std::vector<geom::point<float, 2>> points;
|
std::vector<geom::point<float, 2>> points;
|
||||||
|
|
@ -48,6 +51,7 @@ struct main_scene
|
||||||
gfx::painter painter;
|
gfx::painter painter;
|
||||||
|
|
||||||
util::clock<> clock;
|
util::clock<> clock;
|
||||||
|
util::moving_average<float> update_time{64};
|
||||||
};
|
};
|
||||||
|
|
||||||
main_scene::main_scene(ui::controller & ui_controller)
|
main_scene::main_scene(ui::controller & ui_controller)
|
||||||
|
|
@ -127,7 +131,14 @@ main_scene::main_scene(ui::controller & ui_controller)
|
||||||
});
|
});
|
||||||
precision_slider->set_value(15);
|
precision_slider->set_value(15);
|
||||||
|
|
||||||
layout->set_size(3, 3);
|
auto time_name_label = element_factory.make_label("Computation time:");
|
||||||
|
time_name_label->set_valign(ui::label::valignment::center);
|
||||||
|
time_name_label->set_halign(ui::label::halignment::right);
|
||||||
|
time_value_label = element_factory.make_label("");
|
||||||
|
time_value_label->set_valign(ui::label::valignment::center);
|
||||||
|
time_value_label->set_halign(ui::label::halignment::center);
|
||||||
|
|
||||||
|
layout->set_size(4, 3);
|
||||||
layout->set_column_weight(0, 0.5f);
|
layout->set_column_weight(0, 0.5f);
|
||||||
layout->set_column_weight(1, 0.5f);
|
layout->set_column_weight(1, 0.5f);
|
||||||
layout->set(0, 0, count_name_label);
|
layout->set(0, 0, count_name_label);
|
||||||
|
|
@ -139,6 +150,8 @@ main_scene::main_scene(ui::controller & ui_controller)
|
||||||
layout->set(2, 0, precision_name_label);
|
layout->set(2, 0, precision_name_label);
|
||||||
layout->set(2, 1, precision_value_label);
|
layout->set(2, 1, precision_value_label);
|
||||||
layout->set(2, 2, precision_slider);
|
layout->set(2, 2, precision_slider);
|
||||||
|
layout->set(3, 0, time_name_label);
|
||||||
|
layout->set(3, 1, time_value_label);
|
||||||
|
|
||||||
ui::style style;
|
ui::style style;
|
||||||
style.font = ui::make_default_9x12_font();
|
style.font = ui::make_default_9x12_font();
|
||||||
|
|
@ -310,6 +323,9 @@ void main_scene::update()
|
||||||
edges.push_back({v0, v1});
|
edges.push_back({v0, v1});
|
||||||
degree[v0]++;
|
degree[v0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_time.push(clock.count());
|
||||||
|
time_value_label->set_text(util::to_string(std::setprecision(3), std::fixed, update_time.average() * 1000.f, "ms"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_scene::present()
|
void main_scene::present()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue