diff options
| author | Juan Linietsky | 2016-05-21 21:18:16 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-05-21 21:18:16 -0300 |
| commit | a75f8963380a1f6ae8501f21a1d3f3bef8a89d91 (patch) | |
| tree | ae561ded247f81565c8287b6fd4b816f6ec762e6 /servers/physics_2d/step_2d_sw.cpp | |
| parent | c195c0df6b36debc870216dd42e49fbda70fa861 (diff) | |
| download | godot-a75f8963380a1f6ae8501f21a1d3f3bef8a89d91.tar.gz godot-a75f8963380a1f6ae8501f21a1d3f3bef8a89d91.tar.zst godot-a75f8963380a1f6ae8501f21a1d3f3bef8a89d91.zip | |
First version of Profiler
It is now possible to profile GDScript as well as some parts of Godot
internals.
Diffstat (limited to 'servers/physics_2d/step_2d_sw.cpp')
| -rw-r--r-- | servers/physics_2d/step_2d_sw.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index 4f9d06ee9..4f86168c1 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "step_2d_sw.h" - +#include "os/os.h" void Step2DSW::_populate_island(Body2DSW* p_body,Body2DSW** p_island,Constraint2DSW **p_constraint_island) { @@ -142,6 +142,11 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { const SelfList<Body2DSW>::List * body_list = &p_space->get_active_body_list(); /* INTEGRATE FORCES */ + + uint64_t profile_begtime = OS::get_singleton()->get_ticks_usec(); + uint64_t profile_endtime=0; + + int active_count=0; const SelfList<Body2DSW>*b = body_list->first(); @@ -154,6 +159,13 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { p_space->set_active_objects(active_count); + + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_INTEGRATE_FORCES,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* GENERATE CONSTRAINT ISLANDS */ Body2DSW *island_list=NULL; @@ -190,7 +202,6 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { const SelfList<Area2DSW>::List &aml = p_space->get_moved_area_list(); - while(aml.first()) { for(const Set<Constraint2DSW*>::Element *E=aml.first()->self()->get_constraints().front();E;E=E->next()) { @@ -206,6 +217,13 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } // print_line("island count: "+itos(island_count)+" active count: "+itos(active_count)); + + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_GENERATE_ISLANDS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* SETUP CONSTRAINT ISLANDS */ { @@ -248,6 +266,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_SETUP_CONSTRAINTS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* SOLVE CONSTRAINT ISLANDS */ { @@ -259,6 +283,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_SOLVE_CONSTRAINTS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* INTEGRATE VELOCITIES */ b = body_list->first(); @@ -280,6 +310,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_INTEGRATE_VELOCITIES,profile_endtime-profile_begtime); + //profile_begtime=profile_endtime; + } + p_space->update(); p_space->unlock(); _step++; |
