MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / dumpRecursive

Method dumpRecursive

examples/Utils/b3Quickprof.cpp:288–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286#include <stdio.h>
287
288void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spacing)
289{
290 profileIterator->First();
291 if (profileIterator->Is_Done())
292 return;
293
294 float accumulated_time = 0, parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
295 int i;
296 int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset();
297 for (i = 0; i < spacing; i++) b3Printf(".");
298 b3Printf("----------------------------------\n");
299 for (i = 0; i < spacing; i++) b3Printf(".");
300 b3Printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time);
301 float totalTime = 0.f;
302
303 int numChildren = 0;
304
305 for (i = 0; !profileIterator->Is_Done(); i++, profileIterator->Next())
306 {
307 numChildren++;
308 float current_total_time = profileIterator->Get_Current_Total_Time();
309 accumulated_time += current_total_time;
310 float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
311 {
312 int i;
313 for (i = 0; i < spacing; i++) b3Printf(".");
314 }
315 b3Printf("%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)\n", i, profileIterator->Get_Current_Name(), fraction, (current_total_time / (double)frames_since_reset), profileIterator->Get_Current_Total_Calls());
316 totalTime += current_total_time;
317 //recurse into children
318 }
319
320 if (parent_time < accumulated_time)
321 {
322 b3Printf("what's wrong\n");
323 }
324 for (i = 0; i < spacing; i++) b3Printf(".");
325 b3Printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:", parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
326
327 for (i = 0; i < numChildren; i++)
328 {
329 profileIterator->Enter_Child(i);
330 dumpRecursive(profileIterator, spacing + 3);
331 profileIterator->Enter_Parent();
332 }
333}
334
335void b3ProfileManager::dumpAll()
336{

Callers

nothing calls this directly

Calls 11

FirstMethod · 0.45
Is_DoneMethod · 0.45
Is_RootMethod · 0.45
NextMethod · 0.45
Get_Current_NameMethod · 0.45
Enter_ChildMethod · 0.45
Enter_ParentMethod · 0.45

Tested by

no test coverage detected