Class TCastleProfiler

Unit

Declaration

type TCastleProfiler = class(TObject)

Description

Profiler, to measure the speed of execution of your code. This is usually used only through the singleton Profiler.

The profiler is automatically used by various Castle Game Engine loading routines. It presents the easiest way to answer questions like "which game asset is the most expensive to load".

To get the profile:

  1. Set Enabled to True as early as possible, like in the "initialization" section of your main game unit.

  2. The engine will automatically send to log a profile after TCastleApplication.OnInitialize finished, which is a usual place when loading takes place in simple CGE applications.

    You don't need to do anything, just make sure you have logging enabled (call InitializeLog).

  3. You can display the profile Summary at any point in your application, in any way you like. For example by

    WritelnLogMultiline('Time Profile', Profiler.Summary);

    An alternative way to display the profile is to pass True as a 2nd argument to any Stop call. This allows to display a profile limited to given Start .. Stop pair.

To send your own time information to the profile, call Start and Stop methods around a given time-consuming task. We will measure time and automatically build a tree of tasks (when one larger task contains several smaller tasks).

Contrary to profilers like Valgrind or Gprof (see https://castle-engine.io/optimization#_profile_measure_speed_and_memory_usage , https://castle-engine.io/profiling_using_valgrind ), this profiler does not automatically gather everything. On the other hand, this profiler works on all platforms supported by CGE, and is trivial to use.

Source: base/castletimeutils_profiler.inc (line 97).

Hierarchy

  • TObject
  • TCastleProfiler

Generated by PasDoc 0.17.0.snapshot.