-
-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from marcelofg55/profiling_data
Profiling support
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef GODOT_PROFILING_HPP | ||
#define GODOT_PROFILING_HPP | ||
|
||
#include "OS.hpp" | ||
|
||
|
||
namespace godot { | ||
|
||
class FunctionProfiling { | ||
char signature[1024]; | ||
uint64_t ticks; | ||
|
||
public: | ||
FunctionProfiling(const char *p_function, const int p_line) { | ||
snprintf(signature, 1024, "::%d::%s", p_line, p_function); | ||
ticks = OS::get_singleton()->get_ticks_usec(); | ||
} | ||
~FunctionProfiling() { | ||
uint64_t t = OS::get_singleton()->get_ticks_usec() - ticks; | ||
if (t > 0) { | ||
Godot::gdnative_profiling_add_data(signature, t); | ||
} | ||
} | ||
}; | ||
|
||
} | ||
|
||
#ifdef DEBUG_ENABLED | ||
#define GODOT_PROFILING_FUNCTION FunctionProfiling __function_profiling(__FUNCTION__, __LINE__); | ||
#else | ||
#define GODOT_PROFILING_FUNCTION | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters