1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

First version of Profiler

It is now possible to profile GDScript as well as some parts of Godot
internals.
This commit is contained in:
Juan Linietsky
2016-05-21 21:18:16 -03:00
parent c195c0df6b
commit a75f896338
35 changed files with 2245 additions and 180 deletions

View File

@@ -29,6 +29,8 @@
#include "step_sw.h"
#include "joints_sw.h"
#include "os/os.h"
void StepSW::_populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_constraint_island) {
p_body->set_island_step(_step);
@@ -152,6 +154,10 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
const SelfList<BodySW>::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<BodySW>*b = body_list->first();
@@ -165,6 +171,12 @@ void StepSW::step(SpaceSW* 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(SpaceSW::ELAPSED_TIME_INTEGRATE_FORCES,profile_endtime-profile_begtime);
profile_begtime=profile_endtime;
}
/* GENERATE CONSTRAINT ISLANDS */
BodySW *island_list=NULL;
@@ -214,6 +226,13 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
p_space->area_remove_from_moved_list((SelfList<AreaSW>*)aml.first()); //faster to remove here
}
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();
p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_GENERATE_ISLANDS,profile_endtime-profile_begtime);
profile_begtime=profile_endtime;
}
// print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
/* SETUP CONSTRAINT ISLANDS */
@@ -226,6 +245,12 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
}
}
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();
p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SETUP_CONSTRAINTS,profile_endtime-profile_begtime);
profile_begtime=profile_endtime;
}
/* SOLVE CONSTRAINT ISLANDS */
{
@@ -237,6 +262,13 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
}
}
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();
p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SOLVE_CONSTRAINTS,profile_endtime-profile_begtime);
profile_begtime=profile_endtime;
}
/* INTEGRATE VELOCITIES */
b = body_list->first();
@@ -257,6 +289,12 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
}
}
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();
p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_INTEGRATE_VELOCITIES,profile_endtime-profile_begtime);
profile_begtime=profile_endtime;
}
p_space->update();
p_space->unlock();
_step++;