Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] multiple output-formats #476

Open
wszoecs opened this issue Feb 14, 2024 · 2 comments
Open

[suggestion] multiple output-formats #476

wszoecs opened this issue Feb 14, 2024 · 2 comments

Comments

@wszoecs
Copy link

wszoecs commented Feb 14, 2024

I really welcome the "-O summaryFormat=json" - as it allows more correct/easier parsing and processing of IOR-outputs.
BUT - as I have a lot of "legacy" parsers - I can't easily switch over to 'json' only output.

So it would be practical - to have something like "-O summaryFormat=json,default" - and have BOTH generated.

Sounds 'whacky' at first - I know - but look at FIO - it actually does the SAME! - and the idea works quite well there.
YES - it's quite 'messy' to have first text, then json (or vice versa) - but if you request 'default,json' - you know what you want.
(maybe it should even honor the order - so 'default,json' - or 'json,default' )

I still do need the human-readable text - to be able to show it to someone else.
(you can't paste a json-output into a benchmark report)

But for analyzing a large ammount of runs - having JSON additionally - would be really nice.

@JulianKunkel
Copy link
Collaborator

Good suggestion, not completely trivial.
Parsing and making it understand the requirements such as
$ ./src/ior -O "summaryFormat=json;default;CSV"
is simple. However, the log output is split across various sources. Will think about it.

@JulianKunkel
Copy link
Collaborator

Here is the patch for parsing the input, however, the refactoring for the recursive output would require a major rewrite of various parts as it is reported in line with the code and not written after an experiment is completed. One issue is that errors and output is created as soon as it is available and no information is collected and then written afterwards.
I would stop development here. Maybe someone wants to rewrite the code to collect data (it is partially existing), and then output everything after a run....

diff --git a/src/iordef.h b/src/iordef.h
index ae5dec5..e77a999 100755
--- a/src/iordef.h
+++ b/src/iordef.h
@@ -67,9 +67,9 @@ typedef enum{
 /*************************** D E F I N I T I O N S ****************************/
 
 enum OutputFormat_t{
-  OUTPUT_DEFAULT,
-  OUTPUT_CSV,
-  OUTPUT_JSON
+  OUTPUT_DEFAULT = 1,
+  OUTPUT_CSV = 2,
+  OUTPUT_JSON = 4
 };
 
 #ifndef FALSE
diff --git a/src/parse_options.c b/src/parse_options.c
index 6a44e4e..4762a66 100755
--- a/src/parse_options.c
+++ b/src/parse_options.c
@@ -121,14 +121,22 @@ void DecodeDirective(char *line, IOR_param_t *params, options_all_t * module_opt
         } else if (strcasecmp(option, "savePerOpDataCSV") == 0){
           params->savePerOpDataCSV = strdup(value);
         } else if (strcasecmp(option, "summaryFormat") == 0) {
-                if(strcasecmp(value, "default") == 0){
-                  outputFormat = OUTPUT_DEFAULT;
-                }else if(strcasecmp(value, "JSON") == 0){
-                  outputFormat = OUTPUT_JSON;
-                }else if(strcasecmp(value, "CSV") == 0){
-                  outputFormat = OUTPUT_CSV;
-                }else{
-                  FAIL("Unknown summaryFormat");
+                printf("VALUE %s\n", value);
+                char *saveptr = NULL;
+                char *token = NULL;
+                token = strtok_r(value, ";", & saveptr);
+                outputFormat = 0;
+                while(token != NULL){
+                        if(strcasecmp(token, "default") == 0){
+                        outputFormat |= OUTPUT_DEFAULT;
+                        }else if(strcasecmp(token, "JSON") == 0){
+                        outputFormat |= OUTPUT_JSON;
+                        }else if(strcasecmp(token, "CSV") == 0){
+                        outputFormat |= OUTPUT_CSV;
+                        }else{
+                                FAIL("Unknown summaryFormat");
+                        }
+                        token = strtok_r(NULL, ";", & saveptr);
                 }
         } else if (strcasecmp(option, "refnum") == 0) {
                 params->referenceNumber = atoi(value);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants