consistency

This commit is contained in:
Irlan
2019-03-30 11:51:55 -03:00
parent 812ee84d7e
commit f59df50fbd
6 changed files with 29 additions and 30 deletions

View File

@ -26,7 +26,7 @@ Model::Model()
g_draw = &m_draw;
g_camera = &m_camera;
g_profiler = &m_profiler;
g_profilerRecorder = &m_profilerListener.m_recorderProfiler;
g_profilerRecorder = &m_profilerListener.m_recorderListener;
g_profilerListener = &m_profilerListener;
m_test = nullptr;

View File

@ -81,8 +81,6 @@ void Profiler::End()
listener->BeginEvent(e.name, e.t0);
listener->EndEvent(e.name, e.t1);
listener->Duration(e.name, e.t1 - e.t0);
}
}

View File

@ -92,14 +92,6 @@ public:
B3_NOT_USED(name);
B3_NOT_USED(time);
}
// This function is called when a profiler event ends.
// However it supplies the duration of the last begin and end events.
virtual void Duration(const char* name, float64 duration)
{
B3_NOT_USED(name);
B3_NOT_USED(duration);
}
};
extern ProfilerListener* g_profilerListener;

View File

@ -61,27 +61,35 @@ ProfilerRecord* RecorderProfiler::FindRecord(const char* name)
return nullptr;
}
void RecorderProfiler::Add(const char* name, float64 elapsedTime)
void RecorderProfiler::BeginEvent(const char* name, float64 time)
{
B3_ASSERT(elapsedTime >= 0.0);
++m_call;
ProfilerRecord* fr = FindRecord(name);
if (fr)
{
fr->elapsed += elapsedTime;
fr->maxElapsed = b3Max(fr->maxElapsed, elapsedTime);
fr->time = time;
fr->call = m_call;
return;
}
ProfilerRecord r;
r.name = name;
r.elapsed = elapsedTime;
r.maxElapsed = elapsedTime;
r.time = time;
r.elapsed = 0.0;
r.maxElapsed = 0.0;
r.call = m_call;
m_records.PushBack(r);
}
void RecorderProfiler::EndEvent(const char* name, float64 time)
{
ProfilerRecord* fr = FindRecord(name);
B3_ASSERT(fr != nullptr);
float64 elapsedTime = time - fr->time;
fr->elapsed += elapsedTime;
fr->maxElapsed = b3Max(fr->maxElapsed, elapsedTime);
}

View File

@ -26,6 +26,7 @@
struct ProfilerRecord
{
const char* name;
float64 time;
float64 elapsed;
float64 maxElapsed;
u32 call;
@ -41,7 +42,9 @@ public:
void EndEvents();
void Add(const char* name, float64 elapsedTime);
void BeginEvent(const char* name, float64 time);
void EndEvent(const char* name, float64 time);
ProfilerRecord* FindRecord(const char* name);

View File

@ -36,7 +36,7 @@ class TestbedListener : public ProfilerListener
public:
void BeginEvents() override
{
m_recorderProfiler.BeginEvents();
m_recorderListener.BeginEvents();
#if (PROFILE_JSON == 1)
m_jsonListener.BeginEvents();
@ -46,7 +46,7 @@ public:
void EndEvents() override
{
m_recorderProfiler.EndEvents();
m_recorderListener.EndEvents();
#if (PROFILE_JSON == 1)
m_jsonListener.EndEvents();
@ -56,6 +56,8 @@ public:
void BeginEvent(const char* name, float64 time) override
{
m_recorderListener.BeginEvent(name, time);
#if (PROFILE_JSON == 1)
m_jsonListener.BeginEvent(name, time);
#endif
@ -63,18 +65,14 @@ public:
void EndEvent(const char* name, float64 time) override
{
m_recorderListener.EndEvent(name, time);
#if (PROFILE_JSON == 1)
m_jsonListener.EndEvent(name, time);
#endif
}
void Duration(const char* name, float64 duration) override
{
m_recorderProfiler.Add(name, duration);
}
RecorderProfiler m_recorderProfiler;
RecorderProfiler m_recorderListener;
#if (PROFILE_JSON == 1)
JsonProfiler m_jsonListener;