changes...

This commit is contained in:
2026-08-17 04:24:40 -07:00
parent 47b9a9ae38
commit 6385442711
3 changed files with 22 additions and 20 deletions
+13 -15
View File
@@ -59,7 +59,7 @@ static struct profiler_tree_node *profiler_tree_node(const char *name)
void profiler_begin(const char *name)
{
if(!profiler_root_node) { /* create root node */
profiler_root_node = profiler_tree_node("TOTAL");
profiler_root_node = profiler_tree_node("");
profiler_last_node = profiler_root_node;
}
@@ -80,14 +80,20 @@ void profiler_begin(const char *name)
profiler_last_node = node;
}
void profiler_end()
{
profiler_last_node->data.end = profiler_get_time();
profiler_last_node = profiler_last_node->parent;
}
static void profiler_do_print(struct profiler_tree_node *node,
int indent_level)
int indentation_level)
{
if(node) {
unsigned long long difference;
int i;
for(i = 0; i < indent_level; i++)
for(i = 0; i < indentation_level; i++)
fprintf(stderr, " ");
difference = node->data.end - node->data.start;
@@ -97,12 +103,10 @@ static void profiler_do_print(struct profiler_tree_node *node,
difference,
(double)(difference) / 1000000.0);
if(node->first_child) {
profiler_do_print(node->first_child, indent_level+1);
}
if(node->next_sibling) {
profiler_do_print(node->next_sibling, indent_level);
}
if(node->first_child)
profiler_do_print(node->first_child, indentation_level+1);
if(node->next_sibling)
profiler_do_print(node->next_sibling, indentation_level);
}
}
@@ -111,12 +115,6 @@ void profiler_print()
profiler_do_print(profiler_root_node->first_child, 0);
}
void profiler_end()
{
profiler_last_node->data.end = profiler_get_time();
profiler_last_node = profiler_last_node->parent;
}
#else
#define profiler_begin(...)