zstdcli : moving cpu load calculation from FIO_compressFilename_dstFile to FIO_compressFilename_internal

dev
Ephraim Park 2019-06-04 09:04:35 -07:00
parent 2841c79e87
commit 5fe974261b
1 changed files with 13 additions and 14 deletions

View File

@ -1165,6 +1165,9 @@ FIO_compressFilename_internal(FIO_prefs_t* const prefs,
const char* dstFileName, const char* srcFileName,
int compressionLevel)
{
UTIL_time_t const timeStart = UTIL_getTime();;
clock_t const cpuStart = clock();
U64 readsize = 0;
U64 compressedfilesize = 0;
U64 const fileSize = UTIL_getFileSize(srcFileName);
@ -1217,6 +1220,15 @@ FIO_compressFilename_internal(FIO_prefs_t* const prefs,
(unsigned long long)readsize, (unsigned long long) compressedfilesize,
dstFileName);
/* Elapsed Time and CPU Load */
{ clock_t const cpuEnd = clock();
double const cpuLoad_s = (double)(cpuEnd - cpuStart) / CLOCKS_PER_SEC;
U64 const timeLength_ns = UTIL_clockSpanNano(timeStart);
double const timeLength_s = (double)timeLength_ns / 1000000000;
double const cpuLoad_pct = (cpuLoad_s / timeLength_s) * 100;
DISPLAYLEVEL(4, "%s: Completed in %.2f sec (cpu load : %.0f%%)\n",
srcFileName, timeLength_s, cpuLoad_pct);
}
return 0;
}
@ -1236,9 +1248,6 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
const char* srcFileName,
int compressionLevel)
{
UTIL_time_t timeStart;
clock_t cpuStart;
int closeDstFile = 0;
int result;
stat_t statbuf;
@ -1262,9 +1271,6 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
transfer_permissions = 1;
}
timeStart = UTIL_getTime();
cpuStart = clock();
result = FIO_compressFilename_internal(prefs, ress, dstFileName, srcFileName, compressionLevel);
if (closeDstFile) {
@ -1288,14 +1294,7 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
UTIL_setFileStat(dstFileName, &statbuf);
}
}
{ clock_t const cpuEnd = clock();
double const cpuLoad_s = (double)(cpuEnd - cpuStart) / CLOCKS_PER_SEC;
U64 const timeLength_ns = UTIL_clockSpanNano(timeStart);
double const timeLength_s = (double)timeLength_ns / 1000000000;
double const cpuLoad_pct = (cpuLoad_s / timeLength_s) * 100;
DISPLAYLEVEL(4, "%s: Completed in %.2f sec (cpu load : %.0f%%)\n",
srcFileName, timeLength_s, cpuLoad_pct);
}
return result;
}