You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +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:
@@ -34,7 +34,8 @@
|
||||
#include "joints/slider_joint_sw.h"
|
||||
#include "joints/cone_twist_joint_sw.h"
|
||||
#include "joints/generic_6dof_joint_sw.h"
|
||||
|
||||
#include "script_language.h"
|
||||
#include "os/os.h"
|
||||
|
||||
RID PhysicsServerSW::shape_create(ShapeType p_shape) {
|
||||
|
||||
@@ -1509,12 +1510,51 @@ void PhysicsServerSW::flush_queries() {
|
||||
return;
|
||||
|
||||
doing_sync=true;
|
||||
|
||||
uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
|
||||
|
||||
for( Set<const SpaceSW*>::Element *E=active_spaces.front();E;E=E->next()) {
|
||||
|
||||
SpaceSW *space=(SpaceSW *)E->get();
|
||||
space->call_queries();
|
||||
}
|
||||
|
||||
|
||||
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_profiling()) {
|
||||
|
||||
uint64_t total_time[SpaceSW::ELAPSED_TIME_MAX];
|
||||
static const char* time_name[SpaceSW::ELAPSED_TIME_MAX]={
|
||||
"integrate_forces",
|
||||
"generate_islands",
|
||||
"setup_constraints",
|
||||
"solve_constraints",
|
||||
"integrate_velocities"
|
||||
};
|
||||
|
||||
for(int i=0;i<SpaceSW::ELAPSED_TIME_MAX;i++) {
|
||||
total_time[i]=0;
|
||||
}
|
||||
|
||||
for( Set<const SpaceSW*>::Element *E=active_spaces.front();E;E=E->next()) {
|
||||
|
||||
for(int i=0;i<SpaceSW::ELAPSED_TIME_MAX;i++) {
|
||||
total_time[i]+=E->get()->get_elapsed_time(SpaceSW::ElapsedTime(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Array values;
|
||||
values.resize(SpaceSW::ELAPSED_TIME_MAX*2);
|
||||
for(int i=0;i<SpaceSW::ELAPSED_TIME_MAX;i++) {
|
||||
values[i*2+0]=time_name[i];
|
||||
values[i*2+1]=USEC_TO_SEC(total_time[i]);
|
||||
}
|
||||
values.push_back("flush_queries");
|
||||
values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-time_beg));
|
||||
|
||||
ScriptDebugger::get_singleton()->add_profiling_frame_data("physics",values);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user