PStatCollector

from panda3d.core import PStatCollector
class PStatCollector

Bases:

A lightweight class that represents a single element that may be timed and/or counted via stats.

Collectors can be used to measure two different kinds of values: elapsed time, and “other”.

To measure elapsed time, call start() and stop() as appropriate to bracket the section of code you want to time (or use a PStatTimer to do this automatically).

To measure anything else, call set_level() and/or add_level() to set the “level” value associated with this collector. The meaning of the value set for the “level” is entirely up to the user; it may represent the number of triangles rendered or the kilobytes of texture memory consumed, for instance. The level set will remain fixed across multiple frames until it is reset via another set_level() or adjusted via a call to add_level(). It may also be completely removed via clear_level().

Inheritance diagram

Inheritance diagram of PStatCollector

__init__(copy: PStatCollector)
__init__(parent: PStatCollector, name: str)

Creates a new PStatCollector, ready to start accumulating data. The name of the collector uniquely identifies it among the other collectors; if two collectors share the same name then they are really the same collector.

The parent is the collector that conceptually includes all of the time measured for this collector. For instance, a particular character’s animation time is owned by the “Animation” collector, which is in turn owned by the “Frame” collector. It is not strictly necessary that all of the time spent in a particular collector is completely nested within time spent in its parent’s collector. If parent is the empty string, the collector is owned by “Frame”.

This constructor does not take a client pointer; it always creates the new collector on the same client as its parent.

__init__(name: str, client: PStatClient)

Creates a new PStatCollector, ready to start accumulating data. The name of the collector uniquely identifies it among the other collectors; if two collectors share the same name then they are really the same collector.

The name may also be a compound name, something like “Cull:Sort”, which indicates that this is a collector named “Sort”, a child of the collector named “Cull”. The parent may also be named explicitly by reference in the other flavor of the constructor; see further comments on this for that constructor.

If the client pointer is non-null, it specifies a particular client to register the collector with; otherwise, the global client is used.

add_level(thread: PStatThread, increment: float)

Adds the indicated increment (which may be negative) to the level setting associated with this collector for the indicated thread. If the collector did not already have a level setting for this thread, it is initialized to 0.

add_level(increment: float)

Adds the indicated increment (which may be negative) to the level setting associated with this collector for the main thread. If the collector did not already have a level setting for the main thread, it is initialized to 0.

As an optimization, the data is not immediately set to the PStatClient. It will be sent the next time flush_level() is called.

add_level_now(increment: float)

Calls add_level() and immediately calls flush_level().

add_thread_level(increment: float)

Adds the indicated increment (which may be negative) to the level setting associated with this collector for the current thread. If the collector did not already have a level setting for the current thread, it is initialized to 0.

assign(copy: PStatCollector) PStatCollector
clear_level()

Removes the level setting associated with this collector for the main thread. The collector will no longer show up on any level graphs in the main thread. This implicitly calls flush_level().

clear_level(thread: PStatThread)

Removes the level setting associated with this collector for the indicated thread. The collector will no longer show up on any level graphs in this thread.

clear_thread_level()

Removes the level setting associated with this collector for the current thread. The collector will no longer show up on any level graphs in the current thread.

flush_level()

Updates the PStatClient with the recent results from add_level() and sub_level().

get_fullname() str

Returns the full name of this collector. This includes the names of all the collector’s parents, concatenated together with colons.

get_index() int

Returns the index number of this particular collector within the PStatClient.

get_level() float

Returns the current level value of the given collector in the main thread. This implicitly calls flush_level().

get_level(thread: PStatThread) float

Returns the current level value of the given collector.

get_name() str

Returns the local name of this collector. This is the rightmost part of the fullname, after the rightmost colon.

get_thread_level() float

Returns the current level value of the given collector in the current thread.

is_active() bool

Returns true if this particular collector is active on the default thread, and we are currently transmitting PStats data.

is_active(thread: PStatThread) bool

Returns true if this particular collector is active on the indicated thread, and we are currently transmitting PStats data.

is_started() bool

Returns true if this particular collector has been started on the default thread, or false otherwise.

is_started(thread: PStatThread) bool

Returns true if this particular collector has been started on the indicated thread, or false otherwise.

is_valid() bool

Returns true if collector is valid and may be used, or false if it was constructed with the default constructor (in which case any attempt to use it will crash).

output(out: ostream)
set_level(thread: PStatThread, level: float)

Sets the level setting associated with this collector for the indicated thread to the indicated value.

set_level(level: float)

Sets the level setting associated with this collector for the main thread to the indicated value. This implicitly calls flush_level().

set_thread_level(level: float)

Sets the level setting associated with this collector for the current thread to the indicated value.

start()

Starts this particular timer ticking. This should be called before the code you want to measure.

start(thread: PStatThread)

Starts this timer ticking within a particular thread.

start(thread: PStatThread, as_of: float)

Marks that the timer should have been started as of the indicated time. This must be a time based on the PStatClient’s clock (see PStatClient::get_clock()), and care should be taken that all such calls exhibit a monotonically increasing series of time values.

stop()

Stops this timer. This should be called after the code you want to measure.

stop(thread: PStatThread)

Stops this timer within a particular thread.

stop(thread: PStatThread, as_of: float)

Marks that the timer should have been stopped as of the indicated time. This must be a time based on the PStatClient’s clock (see PStatClient::get_clock()), and care should be taken that all such calls exhibit a monotonically increasing series of time values.

sub_level(thread: PStatThread, decrement: float)

Subtracts the indicated decrement (which may be negative) to the level setting associated with this collector for the indicated thread. If the collector did not already have a level setting for this thread, it is initialized to 0.

sub_level(decrement: float)

Subtracts the indicated decrement (which may be negative) to the level setting associated with this collector for the main thread. If the collector did not already have a level setting for the main thread, it is initialized to 0.

As an optimization, the data is not immediately set to the PStatClient. It will be sent the next time flush_level() is called.

sub_level_now(decrement: float)

Calls sub_level() and immediately calls flush_level().

sub_thread_level(decrement: float)

Subtracts the indicated decrement (which may be negative) to the level setting associated with this collector for the current thread. If the collector did not already have a level setting for the current thread, it is initialized to 0.