Explorar el Código

Improved time tracking / reporting.

git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@51 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist hace 10 años
padre
commit
69e99f6fee
Se han modificado 2 ficheros con 17 adiciones y 6 borrados
  1. 9
    5
      snfLOGmgr.cpp
  2. 8
    1
      snfLOGmgr.hpp

+ 9
- 5
snfLOGmgr.cpp Ver fichero

@@ -405,7 +405,7 @@ bool snfLOGmgr::do_SecondReport() {

Report << "\t<timers>" << endl;
Report << "\t\t<run started=\'" << Timestamp(StartupTime) << "\' "
<< "elapsed=\'" << (int) difftime(Timestamp(), StartupTime) << "\'/>" << endl;
<< "elapsed=\'" << SecsSinceStartup() << "\'/>" << endl;

Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;
@@ -573,7 +573,7 @@ bool snfLOGmgr::do_MinuteReport() {

Report << "\t<timers>" << endl;
Report << "\t\t<run started=\'" << Timestamp(StartupTime) << "\' "
<< "elapsed=\'" << (int) difftime(Timestamp(), StartupTime) << "\'/>" << endl;
<< "elapsed=\'" << SecsSinceStartup() << "\'/>" << endl;

Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;
@@ -740,7 +740,7 @@ bool snfLOGmgr::do_HourReport() {

Report << "\t<timers>" << endl;
Report << "\t\t<run started=\'" << Timestamp(StartupTime) << "\' "
<< "elapsed=\'" << (int) difftime(Timestamp(), StartupTime) << "\'/>" << endl;
<< "elapsed=\'" << SecsSinceStartup() << "\'/>" << endl;

Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;
@@ -1731,7 +1731,7 @@ bool snfLOGmgr::OkToSample(int SampleOneInX) {

time_t snfLOGmgr::Timestamp() { // Get an ordinary timestamp.
time_t rawtime;
time(&rawtime);
rawtime = time(NULL);
return rawtime;
}

@@ -1840,6 +1840,10 @@ void snfLOGPersistentState::restore(string& FileNameToRestore) {
// 20090730_M - Moved persistent state aux saves to RecordSyncEvent. It makes
// sense for the persistent state to match the latext external record of state
// info. If SNFServer dies uncerimoneusly that is what we will remember.
int snfLOGmgr::SecsSinceStartup() {
return (int) difftime(Timestamp(), StartupTime);
}

void snfLOGmgr::RecordSyncEvent() { // Sets timestamp of latest Sync.
Status.LastSyncTime = Timestamp(); // Set the Sync time.
@@ -1863,7 +1867,7 @@ void snfLOGmgr::RecordCondenseEvent() {
}

int snfLOGmgr::SecsSinceLastCondense() { // Gets seconds since latest Condense.
return (int) difftime(Timestamp(), Status.LastCondenseTime);
return (int) difftime(Timestamp(), Status.LastCondenseTime);
}

// Data in the multi-range sliding window is tracked in circular buffers.

+ 8
- 1
snfLOGmgr.hpp Ver fichero

@@ -440,7 +440,13 @@ class IntervalTimer {
class snfLOGPersistentState {
public:

snfLOGPersistentState() : Ready(0) {}
snfLOGPersistentState() :
Ready(0),
LastSyncTime(0),
LastSaveTime(0),
LastCondenseTime(0),
LatestRuleID(0),
SerialNumberCounter(0) {}

bool Ready; // True if we're ready to use.

@@ -634,6 +640,7 @@ class snfLOGmgr : private Thread {
unsigned int SerialNumber(); // Returns the next serial number.
string& SerialNumber(string& s); // Appends the next serial number.

int SecsSinceStartup(); // Gets seconds since starup.
void RecordSyncEvent(); // Sets timestamp of latest Sync.
int SecsSinceLastSync(); // Gets seconds since latest Sync.
void RecordSaveEvent(); // Sets timestamp of latest Save.

Cargando…
Cancelar
Guardar