Browse Source

Improved time tracking / reporting.

git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@51 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 10 years ago
parent
commit
69e99f6fee
2 changed files with 17 additions and 6 deletions
  1. 9
    5
      snfLOGmgr.cpp
  2. 8
    1
      snfLOGmgr.hpp

+ 9
- 5
snfLOGmgr.cpp View File



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


Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' " Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl; << "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;


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


Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' " Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl; << "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;


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


Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' " Report << "\t\t<sync latest=\'" << Timestamp(Status.LastSyncTime) << "\' "
<< "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl; << "elapsed=\'" << SecsSinceLastSync() << "\'/>" << endl;


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


// 20090730_M - Moved persistent state aux saves to RecordSyncEvent. It makes // 20090730_M - Moved persistent state aux saves to RecordSyncEvent. It makes
// sense for the persistent state to match the latext external record of state // sense for the persistent state to match the latext external record of state
// info. If SNFServer dies uncerimoneusly that is what we will remember. // 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. void snfLOGmgr::RecordSyncEvent() { // Sets timestamp of latest Sync.
Status.LastSyncTime = Timestamp(); // Set the Sync time. Status.LastSyncTime = Timestamp(); // Set the Sync time.
} }


int snfLOGmgr::SecsSinceLastCondense() { // Gets seconds since latest Condense. 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. // Data in the multi-range sliding window is tracked in circular buffers.

+ 8
- 1
snfLOGmgr.hpp View File

class snfLOGPersistentState { class snfLOGPersistentState {
public: 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. bool Ready; // True if we're ready to use.


unsigned int SerialNumber(); // Returns the next serial number. unsigned int SerialNumber(); // Returns the next serial number.
string& SerialNumber(string& s); // Appends 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. void RecordSyncEvent(); // Sets timestamp of latest Sync.
int SecsSinceLastSync(); // Gets seconds since latest Sync. int SecsSinceLastSync(); // Gets seconds since latest Sync.
void RecordSaveEvent(); // Sets timestamp of latest Save. void RecordSaveEvent(); // Sets timestamp of latest Save.

Loading…
Cancel
Save