diff --git a/TestPrograms/sysCallMeasurement/SysCallStat.h b/TestPrograms/sysCallMeasurement/SysCallStat.h index 50fb6354..05c29277 100644 --- a/TestPrograms/sysCallMeasurement/SysCallStat.h +++ b/TestPrograms/sysCallMeasurement/SysCallStat.h @@ -1,6 +1,11 @@ - #ifndef SYS_CALL_STAT #define SYS_CALL_STAT +/* +uncomment the line below to measure open, close, read,write system calls for 'enc' command. +*/ +/*#define MEASURE_SYS_CALLS*/ + +#ifdef MEASURE_SYS_CALLS #include #include #include @@ -39,3 +44,4 @@ TASK_ID sysCallTaskID; static SEM_ID sysCallSemID; UINT32 tsFreq; #endif +#endif diff --git a/TestPrograms/sysCallMeasurement/sysCallStat.c b/TestPrograms/sysCallMeasurement/sysCallStat.c index 88b0d920..276dec36 100644 --- a/TestPrograms/sysCallMeasurement/sysCallStat.c +++ b/TestPrograms/sysCallMeasurement/sysCallStat.c @@ -1,4 +1,5 @@ #include "sysCallStat.h" +#ifdef MEASURE_SYS_CALLS extern KRNL_API_STATS API_STATS[sysCallMax]; /* "enc", "-pbkdf2 -aes-256-cbc -in plain.txt -out cipher.enc -kfile keyfile.key" */ void clearSysTableData() @@ -51,16 +52,33 @@ void CaptureSysCallMetrics(const char* cmd, const char* arg) semDelete(sysCallSemID); } + void displayStats() { - printf("------------------------------------------------------------------\n"); - printf("%-15s %-15s %-15s %-20s\n","crypto cmd","system call","Invocations","Total time (USec)"); - printf("------------------------------------------------------------------\n"); - printf("%-15s %-15s %-15d %-20lu\n","enc","open",API_STATS[openCall].sysCallCount,((API_STATS[openCall].execTimeUsec)*1000000ULL)/tsFreq); - printf("%-15s %-15s %-15d %-20lu\n","enc","close",API_STATS[closeCall].sysCallCount,((API_STATS[closeCall].execTimeUsec)*1000000ULL)/tsFreq); - printf("%-15s %-15s %-15d %-20lu\n","enc","read",API_STATS[readCall].sysCallCount,((API_STATS[readCall].execTimeUsec)*1000000ULL)/tsFreq ); - printf("%-15s %-15s %-15d %-20lu\n","enc","write",API_STATS[writeCall].sysCallCount,((API_STATS[writeCall].execTimeUsec)*1000000ULL)/tsFreq); - printf("-------------------------------------------------------------------\n"); + UINT64 openTimeUsec = 0; + UINT64 closeTimeUsec = 0; + UINT64 readTimeUsec = 0; + UINT64 writeTimeUsec = 0; + + if (tsFreq == 0) + { + printf("ERROR: tsFreq is zero\n"); + return; + } + openTimeUsec = (API_STATS[openCall].execTimeUsec * 1000000ULL) / (UINT64)tsFreq; + closeTimeUsec = (API_STATS[closeCall].execTimeUsec * 1000000ULL) / (UINT64)tsFreq; + readTimeUsec = (API_STATS[readCall].execTimeUsec * 1000000ULL) / (UINT64)tsFreq; + writeTimeUsec = (API_STATS[writeCall].execTimeUsec * 1000000ULL) / (UINT64)tsFreq; + + printf("------------------------------------------------------------------\n"); + printf("%-15s %-15s %-15s %-20s\n","crypto cmd","system call","Invocations","Total time (USec)"); + printf("------------------------------------------------------------------\n"); + printf("%-15s %-15s %-15u %-20llu\n","enc","open",API_STATS[openCall].sysCallCount,openTimeUsec); + printf("%-15s %-15s %-15u %-20llu\n","enc","close",API_STATS[closeCall].sysCallCount,closeTimeUsec); + printf("%-15s %-15s %-15u %-20llu\n","enc","read",API_STATS[readCall].sysCallCount,readTimeUsec); + printf("%-15s %-15s %-15u %-20llu\n","enc","write",API_STATS[writeCall].sysCallCount,writeTimeUsec); + printf("------------------------------------------------------------------\n"); } +#endif diff --git a/vxworks-6.9/target/src/os/io/ioLib.c b/vxworks-6.9/target/src/os/io/ioLib.c index f25ddaa7..ad2300d2 100644 --- a/vxworks-6.9/target/src/os/io/ioLib.c +++ b/vxworks-6.9/target/src/os/io/ioLib.c @@ -324,7 +324,7 @@ the VxWorks programmer guides. * uncomment the line below to measure open, close, read * and write system calls for 'enc' command. */ -#define MEASURE_SYS_CALLS +/* #define MEASURE_SYS_CALLS */ #ifdef MEASURE_SYS_CALLS