add some simple lock profiling

This commit is contained in:
Glenn Maynard
2002-12-21 05:13:45 +00:00
parent 506f499478
commit 4a2bd2a9db
2 changed files with 48 additions and 3 deletions
+24
View File
@@ -13,6 +13,9 @@
#include "stdafx.h"
#include "RageThreads.h"
#include "RageTimer.h"
#include "RageLog.h"
#include "RageUtil.h"
RageMutex::RageMutex()
{
@@ -69,6 +72,27 @@ void RageMutex::Unlock()
SDL_UnlockMutex(mut);
}
LockMutex::LockMutex(RageMutex &mut, const char *file_, int line_):
mutex(mut),
file(file_),
line(line_),
locked_at(RageTimer::GetTimeSinceStart())
{
mutex.Lock();
}
LockMutex::~LockMutex()
{
mutex.Unlock();
if(file)
{
float dur = RageTimer::GetTimeSinceStart() - locked_at;
if(dur > 0.015)
LOG->Trace(ssprintf("Lock at %s:%i took %f", file, line, dur));
}
}
/*
-----------------------------------------------------------------------------
File: RageThreads