#include <PerfHistory/PerfHistory.hpp>

PerfHistory PerfHistory::frame(1024);

PerfHistory::PerfHistory(int numTimelines) :
    timelines((size_t) numTimelines),
    numTimelines(numTimelines)
{}

void PerfHistory::beginTimeline()
{
    currentTimeline = (currentTimeline + 1) % numTimelines;
    timelines[currentTimeline].reset();
}

PerfTimeline& PerfHistory::getTimeline(int offset)
{
    int index = currentTimeline + offset;
    while (index < 0) index += numTimelines;
    index %= numTimelines;

    return timelines[index];
}