Pretty printing for normal output.

master
Julian M. Kunkel 2018-07-08 16:56:04 +01:00
parent 2bc30410cc
commit 0f17d4860f
2 changed files with 19 additions and 13 deletions

View File

@ -28,7 +28,7 @@ static int indent = 0;
static int needNextToken = 0; static int needNextToken = 0;
static void PrintIndent(){ static void PrintIndent(){
if(outputFormat == OUTPUT_CSV){ if(outputFormat != OUTPUT_JSON){
return; return;
} }
for(int i=0; i < indent; i++){ for(int i=0; i < indent; i++){
@ -40,10 +40,8 @@ static void PrintIndent(){
static void PrintKeyValStart(char * key){ static void PrintKeyValStart(char * key){
PrintNextToken(); PrintNextToken();
if (outputFormat == OUTPUT_DEFAULT){ if (outputFormat == OUTPUT_DEFAULT){
for(int i=0; i < indent; i++){ PrintIndent();
fprintf(out_resultfile, " "); fprintf(out_resultfile, "%-20s: ", key);
}
fprintf(out_resultfile, "%s: ", key);
return; return;
} }
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
@ -53,6 +51,12 @@ static void PrintKeyValStart(char * key){
} }
} }
static void PrintNewLine(){
if (outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "\n");
}
}
static void PrintNextToken(){ static void PrintNextToken(){
if(needNextToken){ if(needNextToken){
needNextToken = 0; needNextToken = 0;
@ -81,7 +85,7 @@ static void PrintKeyVal(char * key, char * value){
PrintNextToken(); PrintNextToken();
needNextToken = 1; needNextToken = 1;
if (outputFormat == OUTPUT_DEFAULT){ if (outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%s: %s\n", key, value); fprintf(out_resultfile, "%-20s: %s\n", key, value);
return; return;
} }
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
@ -95,7 +99,7 @@ static void PrintKeyValDouble(char * key, double value){
PrintNextToken(); PrintNextToken();
needNextToken = 1; needNextToken = 1;
if (outputFormat == OUTPUT_DEFAULT){ if (outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%s: %.4f\n", key, value); fprintf(out_resultfile, "%-20s: %.4f\n", key, value);
return; return;
} }
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
@ -110,7 +114,7 @@ static void PrintKeyValInt(char * key, int64_t value){
PrintNextToken(); PrintNextToken();
needNextToken = 1; needNextToken = 1;
if (outputFormat == OUTPUT_DEFAULT){ if (outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%s: %lld\n", key, (long long) value); fprintf(out_resultfile, "%-20s: %lld\n", key, (long long) value);
return; return;
} }
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
@ -134,10 +138,11 @@ static void PrintNamedSectionStart(char * key){
PrintNextToken(); PrintNextToken();
needNextToken = 0; needNextToken = 0;
indent++; indent++;
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
fprintf(out_resultfile, "\"%s\": {\n", key); fprintf(out_resultfile, "\"%s\": {\n", key);
}else if(outputFormat == OUTPUT_DEFAULT){ }else if(outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%s: \n", key); fprintf(out_resultfile, "\n%s: \n", key);
} }
} }
@ -148,7 +153,7 @@ static void PrintNamedArrayStart(char * key){
if(outputFormat == OUTPUT_JSON){ if(outputFormat == OUTPUT_JSON){
fprintf(out_resultfile, "\"%s\": [\n", key); fprintf(out_resultfile, "\"%s\": [\n", key);
}else if(outputFormat == OUTPUT_DEFAULT){ }else if(outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%s: \n", key); fprintf(out_resultfile, "\n%s: \n", key);
} }
} }
@ -323,6 +328,7 @@ void ShowTestStart(IOR_param_t *test)
PrintKeyValInt("stoneWallingWearOut", test->stoneWallingWearOut); PrintKeyValInt("stoneWallingWearOut", test->stoneWallingWearOut);
PrintKeyValInt("maxTimeDuration", test->maxTimeDuration); PrintKeyValInt("maxTimeDuration", test->maxTimeDuration);
PrintKeyValInt("outlierThreshold", test->outlierThreshold); PrintKeyValInt("outlierThreshold", test->outlierThreshold);
PrintKeyVal("options", test->options); PrintKeyVal("options", test->options);
PrintKeyValInt("nodes", test->nodes); PrintKeyValInt("nodes", test->nodes);
PrintKeyValInt("memoryPerTask", (unsigned long) test->memoryPerTask); PrintKeyValInt("memoryPerTask", (unsigned long) test->memoryPerTask);

View File

@ -408,9 +408,9 @@ void ShowFileSystemSize(char *fileSystem)
} }
if(outputFormat == OUTPUT_DEFAULT){ if(outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "Path: %s\n", realPath); fprintf(out_resultfile, "%-20s: %s\n", "Path", realPath);
fprintf(out_resultfile, "FS: %.1f %s Used FS: %2.1f%% ", fprintf(out_resultfile, "%-20s: %.1f %s Used FS: %2.1f%% ",
totalFileSystemSizeHR, fileSystemUnitStr, "FS", totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage); usedFileSystemPercentage);
fprintf(out_resultfile, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n", fprintf(out_resultfile, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n",
(double)totalInodes / (double)(1<<20), (double)totalInodes / (double)(1<<20),