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 setLevel() and/or addLevel() 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 setLevel() or adjusted via a call to addLevel(). It may also be completely removed via clearLevel().

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.

addLevel(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.

addLevel(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 flushLevel() is called.

addLevelNow(increment: float)

Calls addLevel() and immediately calls flushLevel().

addThreadLevel(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
clearLevel()

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 flushLevel().

clearLevel(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.

clearThreadLevel()

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.

flushLevel()

Updates the PStatClient with the recent results from addLevel() and subLevel().

getFullname() str

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

getIndex() int

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

getLevel() float

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

getLevel(thread: PStatThread) float

Returns the current level value of the given collector.

getName() str

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

getThreadLevel() float

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

isActive() bool

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

isActive(thread: PStatThread) bool

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

isStarted() bool

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

isStarted(thread: PStatThread) bool

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

isValid() 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)
setLevel(thread: PStatThread, level: float)

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

setLevel(level: float)

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

setThreadLevel(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.

subLevel(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.

subLevel(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 flushLevel() is called.

subLevelNow(decrement: float)

Calls subLevel() and immediately calls flushLevel().

subThreadLevel(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.