Initial Commit:
- Create single library for all Core RedA functions/classes - Working version
This commit is contained in:
51
TimingCore.cpp
Normal file
51
TimingCore.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Timing.cpp
|
||||
*
|
||||
* Created on: 13 May 2016
|
||||
* Author: wentzelc
|
||||
*/
|
||||
|
||||
// redA Librarie
|
||||
#include "TimingCore.h"
|
||||
|
||||
// Standard C/C++ Libraries
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Set time
|
||||
void SetInterval( timeval * Time, long MilliSeconds )
|
||||
{
|
||||
// milli-seconds -> seconds
|
||||
Time->tv_sec = MilliSeconds / 1000;
|
||||
// milli-seconds -> micro-seconds
|
||||
Time->tv_usec = (MilliSeconds % 1000) * 1000;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Populated start time
|
||||
void SetStartTime( timeval * StartTime )
|
||||
{
|
||||
// Get current time
|
||||
gettimeofday( StartTime, NULL );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Calculate TimePassed from Start Time (in milli-seconds)
|
||||
long TimePassed( timeval StartTime )
|
||||
{
|
||||
timeval CurrTime;
|
||||
long Duration;
|
||||
|
||||
// Get current time
|
||||
gettimeofday( &CurrTime, NULL );
|
||||
|
||||
// Get time passed in milli-seconds
|
||||
Duration = (CurrTime.tv_sec - StartTime.tv_sec) * 1000 +
|
||||
(CurrTime.tv_usec - StartTime.tv_usec) / 1000;
|
||||
|
||||
return Duration;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user