From 059fed7530d2318280fdd1c5442dcc118b0ee999 Mon Sep 17 00:00:00 2001 From: jihoonl Date: Wed, 17 Feb 2010 01:42:13 +0000 Subject: [PATCH] print out recovery time in micro second --- .../src/Runtime/DSTM/interface_recovery/dstm.h | 2 ++ .../Runtime/DSTM/interface_recovery/dstmserver.c | 8 ++++++++ .../src/Runtime/DSTM/interface_recovery/trans.c | 16 +++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstm.h b/Robust/src/Runtime/DSTM/interface_recovery/dstm.h index b88591e9..5a1e4a1f 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstm.h +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstm.h @@ -367,6 +367,8 @@ plistnode_t *pInsert(plistnode_t *pile, objheader_t *headeraddr, unsigned int mi void commitCountForObjRead(char *, unsigned int *, unsigned int *, int *, int *, int *, int *, int *, unsigned int, unsigned short); void commitCountForObjMod(char *, unsigned int *, unsigned int *, int *, int *, int *, int *, int *, unsigned int, unsigned short); +long long myrdtsc(void); + /* Sends notification request for thread join, if sucessful returns 0 else returns -1 */ #ifdef RECOVERY int reqNotify(unsigned int *oidarry, unsigned short *versionarry, unsigned int numoid,int mid); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c index 84329c23..2daa08e3 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c @@ -57,6 +57,14 @@ extern int leader; extern int paxosRound; /* This function initializes the main objects store and creates the * global machine and location lookup table */ + +long long myrdtsc(void) +{ + unsigned hi, lo; + __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); + return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); +} + #endif int dstmInit(void) { diff --git a/Robust/src/Runtime/DSTM/interface_recovery/trans.c b/Robust/src/Runtime/DSTM/interface_recovery/trans.c index 2a4249a0..ad2c1b08 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/trans.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/trans.c @@ -25,6 +25,8 @@ #include #include #include "tlookup.h" + +#define CPU_FREQ 3056842 #endif #define NUM_THREADS 1 @@ -118,7 +120,7 @@ int paxosRound; **************************************/ int numRecovery=0; unsigned int deadMachine[8] ={ 0,0,0,0,0,0,0,0}; -double elapsedTime[8] = {0,0,0,0,0,0,0,0}; +long long elapsedTime[8] = {0,0,0,0,0,0,0,0}; #endif #endif @@ -2521,10 +2523,10 @@ void duplicateLostObjects(unsigned int mid){ #ifdef RECOVERYSTATS printf("Recovery Start\n"); numRecovery++; - time_t st; - time_t fi; + long long st; + long long fi; - time(&st); + st = myrdtsc(); // to get clock deadMachine[numRecovery-1] = mid; #endif @@ -2613,8 +2615,8 @@ void duplicateLostObjects(unsigned int mid){ } #ifdef RECOVERYSTATS - time(&fi); - elapsedTime[numRecovery-1] = fi-st; + fi = myrdtsc(); + elapsedTime[numRecovery-1] = (fi-st)/CPU_FREQ; printRecoveryStat(); #endif @@ -3471,7 +3473,7 @@ void printRecoveryStat() { int i; for(i=0; i < numRecovery;i++) { printf("Dead Machine = %s\n",midtoIPString(deadMachine[i])); - printf("Recovery Time = %.6f\n",elapsedTime[i]); + printf("Recovery Time = %ld\n",elapsedTime[i]); } printf("**************************\n\n"); } -- 2.34.1