Drag[en]gine Script Module DragonScript  1.23
Dragengine.RuntimeMeter Class Reference

Runtime meter. More...

Inheritance diagram for Dragengine.RuntimeMeter:

Public Member Functions

Constructors
RuntimeMeter new ()
 Create runtime meter. More...
 
Management
void reset (int meter)
 Reset meter by 0-based index. More...
 
void reset (int meterFirst, int meterCount)
 Reset range of meters by 0-based index. More...
 
float elapsed (int meter)
 Elapsed time in seconds for meter. More...
 
int elapsedMicroSec (int meter)
 Elapsed time in micro-seconds for meter. More...
 
void counterReset (int counter)
 Reset counter. More...
 
void counterReset (int counterFirst, int counterCount)
 Reset range of counters. More...
 
void counterAdd (int meter, int counter)
 Add elapsed time in micro-seconds off meter to a counter. More...
 
int counterTime (int counter)
 Accumulated time in a counter in micro-seconds. More...
 
float counterTimeSeconds (int counter)
 Accumulated time in a counter in seconds. More...
 
int counterUpdates (int counter)
 Number of times a counter has been incremented. More...
 
int counterAverageTime (int counter)
 Average time per update from a counter in micro-seconds. More...
 
float counterAverageTimeSeconds (int counter)
 Average time per update from a counter in seconds. More...
 

Detailed Description

Runtime meter.

Support for time consumption testing for debugging purpose.

TO do timing measuring reset the count of counters you would like to keep track off. Then reset the count of meters matching the count of concurrent timers you want to keep track off. At appropriate times call counterAdd() to add the accumulated time in a meter to a counter. The meter is reset at the time counterAdd() is called. Once finished you can retrieve the accumulated time from the counters.

The following code shows an example flow:

class MyClass
public func new()
// Create run time meter
var RuntimeMeter rm = RuntimeMeter.new()
// Reset 3 counters. The first two counters will be used to time individual
// function calls while the third one is used to time the grand total.
// This is an example of concurrent timming sampling
rm.counterReset(0, 3)
// Start sampling. Reset 2 meters. They start running now
rm.reset(0, 2)
// Run first function then sample the time from meter 0 and add it to counter 0.
// The meter is reset now
runFunction1()
rm.counterAdd(0, 0)
// Run second function the sample the time from meter 0 and add it to counter 1.
// The meter is reset now
runFunction2()
rm.counterAdd(0, 1)
// During this time the second meter continued running. Sample time from
// meter 1 and add it to counter 2.
rm.counterAdd(1, 2)
// Now we can print out the timings of counter 0 (runFunction1), counter 1
// (runFunction2) and counter 2 (runFunction1 + runFunction2)
var Console c = BaseGameApp.getApp().getConsole()
c.addMessage("Timings: runFunction1: " + rm.counterTime(0))
c.addMessage("Timings: runFunction2: " + rm.counterTime(1))
c.addMessage("Timings: runFunction1 and runFunction2: " + rm.counterTime(2))
end
end
void counterReset(int counter)
Reset counter.
int counterTime(int counter)
Accumulated time in a counter in micro-seconds.
void counterAdd(int meter, int counter)
Add elapsed time in micro-seconds off meter to a counter.
RuntimeMeter new()
Create runtime meter.

This is a native class.

Member Function Documentation

◆ counterAdd()

void Dragengine.RuntimeMeter.counterAdd ( int  meter,
int  counter 
)

Add elapsed time in micro-seconds off meter to a counter.

Resets the meter to 0 afterwards.

◆ counterAverageTime()

int Dragengine.RuntimeMeter.counterAverageTime ( int  counter)

Average time per update from a counter in micro-seconds.

If no updates have been done 0 is returned.

◆ counterAverageTimeSeconds()

float Dragengine.RuntimeMeter.counterAverageTimeSeconds ( int  counter)

Average time per update from a counter in seconds.

Version
1.7

If no updates have been done 0 is returned.

◆ counterReset() [1/2]

void Dragengine.RuntimeMeter.counterReset ( int  counter)

Reset counter.

If not used yet the counter is created.

◆ counterReset() [2/2]

void Dragengine.RuntimeMeter.counterReset ( int  counterFirst,
int  counterCount 
)

Reset range of counters.

If not used yet the counters are created.

◆ counterTime()

int Dragengine.RuntimeMeter.counterTime ( int  counter)

Accumulated time in a counter in micro-seconds.

◆ counterTimeSeconds()

float Dragengine.RuntimeMeter.counterTimeSeconds ( int  counter)

Accumulated time in a counter in seconds.

Version
1.7

◆ counterUpdates()

int Dragengine.RuntimeMeter.counterUpdates ( int  counter)

Number of times a counter has been incremented.

◆ elapsed()

float Dragengine.RuntimeMeter.elapsed ( int  meter)

Elapsed time in seconds for meter.

Resets the meter to 0 after returning.

◆ elapsedMicroSec()

int Dragengine.RuntimeMeter.elapsedMicroSec ( int  meter)

Elapsed time in micro-seconds for meter.

Resets the meter to 0 after returning.

◆ new()

RuntimeMeter Dragengine.RuntimeMeter.new ( )

Create runtime meter.

◆ reset() [1/2]

void Dragengine.RuntimeMeter.reset ( int  meter)

Reset meter by 0-based index.

If not used yet the meter is created.

◆ reset() [2/2]

void Dragengine.RuntimeMeter.reset ( int  meterFirst,
int  meterCount 
)

Reset range of meters by 0-based index.

If not used yet the meters are created.


The documentation for this class was generated from the following file: