about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2020-10-01 12:07:07 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-11-11 14:13:35 +0000
commit62c23484d964556f6e77407752e34f4a974397f9 (patch)
tree9b8e5253755e08ab1d1fad97e6ac185046705d78
parent29a5355a2f15b5653ad2c5b0fbbcb724976ede3f (diff)
downloadklee-62c23484d964556f6e77407752e34f4a974397f9.tar.gz
klee-stats: add (readable) csv format (--table-format=readable-csv/csv)
-rwxr-xr-xtools/klee-stats/klee-stats52
1 files changed, 34 insertions, 18 deletions
diff --git a/tools/klee-stats/klee-stats b/tools/klee-stats/klee-stats
index 82b50279..5028435c 100755
--- a/tools/klee-stats/klee-stats
+++ b/tools/klee-stats/klee-stats
@@ -372,13 +372,8 @@ def write_table(args, data, dirs, pr):
     table = final_table
 
     # Output table
-    if args.tableFormat != 'klee':
-        print(tabulate(
-            table, headers='keys',
-            tablefmt=args.tableFormat,
-            floatfmt='.{p}f'.format(p=2),
-            numalign='right', stralign='center'))
-    else:
+    # - KLEE standard format
+    if args.tableFormat == 'klee':
         stream = tabulate(
             table, headers='keys',
             tablefmt=KleeTable,
@@ -390,6 +385,27 @@ def write_table(args, data, dirs, pr):
             stream.insert(-2, stream[-1])
             stream = '\n'.join(stream)
         print(stream)
+    # - (readable) csv
+    elif args.tableFormat in ['csv', 'readable-csv']:
+        CsvTable = TableFormat(
+            lineabove = None, linebelowheader = None,
+            linebetweenrows = None, linebelow = None,
+            headerrow = DataRow('', ',', ''),
+            datarow = DataRow('', ',', ''),
+            padding = 0, with_header_hide = None)
+        print(tabulate(
+            table, headers='keys',
+            tablefmt=CsvTable,
+            floatfmt='.{p}f'.format(p=2),
+            numalign='decimal' if args.tableFormat == 'readable-csv' else None,
+            stralign='left' if args.tableFormat == 'readable-csv' else None))
+    # - user-defined
+    else:
+        print(tabulate(
+            table, headers='keys',
+            tablefmt=args.tableFormat,
+            floatfmt='.{p}f'.format(p=2),
+            numalign='right', stralign='center'))
 
 
 def main():
@@ -413,22 +429,22 @@ def main():
 
     if tabulate_available:
         parser.add_argument('--table-format',
-                              choices=['klee'] + list(_table_formats.keys()),
-                              dest='tableFormat', default='klee',
-                              help='Table format for the summary.')
+                            choices=['klee', 'csv', 'readable-csv'] + list(_table_formats.keys()),
+                            dest='tableFormat', default='klee',
+                            help='Table format for the summary.')
 
     parser.add_argument('--to-csv',
-                          action='store_true', dest='toCsv',
-                          help='Output stats as comma-separated values (CSV)')
+                        action='store_true', dest='toCsv',
+                        help='Output run.stats data as comma-separated values (CSV)')
     parser.add_argument('--grafana',
-                          action='store_true', dest='grafana',
-                          help='Start a grafana web server')
+                        action='store_true', dest='grafana',
+                        help='Start a grafana web server')
     parser.add_argument('--grafana-host', dest='grafana_host',
-                          help='IP address grafana web server should listen to',
-                          default="127.0.0.1")
+                        help='IP address grafana web server should listen to',
+                        default="127.0.0.1")
     parser.add_argument('--grafana-port', dest='grafana_port', type=int,
-                          help='Port grafana web server should listen to',
-                          default=5000)
+                        help='Port grafana web server should listen to',
+                        default=5000)
 
     # argument group for controlling output verboseness
     pControl = parser.add_mutually_exclusive_group(required=False)