Latest version:
Tramway SDK 0.0.9
Github
Quick links
Home
Get Started

Statistics


The statistics system collects data. There are two different types of data.

The first type is time. Each System gets its own time counter. Systems can add time spent in themselves to the counter.

The second type is the counter counter. It provides arbitrary counting services. For example, the Render system uses this service to count up an approximation of how much GPU memory it is using.

Programming in C++


#include <framework/system.h>
API documentation page.

For the timings, somewhere in your main loop you need to add a call to the collate function.

// main loop
while (true) {
    Stats::Collate();
}

After that, you can start counting stuff.

system_t frog_system = System::Register("frog");

Stats::Start(frog_system);

pet_frogs();
feed_frogs();
bathe_frogs();

Stats::Stop(frog_system);

Stats::Add(RESOURCE_FROG, inital_frogs);
Stats::Remove(RESOURCE_FROG, escaped_frogs);

Finally, you can retrieve your counts.

size_t frogs = Stats::GetStat(RESOURCE_FROG);
float frog_time = Stats::GetStat(frog_system);