Commits

Yit Phang Khoo committed 7861a08

Move units from benchmark log to benchmark config.

  • Participants
  • Parent commits c3efb81

Comments (0)

Files changed (2)

File Benchmarks/BenchmarkAdapton/runbenchmarkadapton.ml

         Printf.fprintf ff "{\"name\":%S,\"take\":%S}"
             (fst task) (match snd task with `One _ -> "one" | `List _ -> "list" | `Flip _ -> "flip" | `ExpTree -> "exptree")
     in
-    Printf.printf "{\"modules\":[%a],\"tasks\":[%a]}\n%!"
+    Printf.printf "{\"modules\":[%a],\"tasks\":[%a],%s}\n%!"
         (list_printer (fun ff -> Printf.fprintf ff "%S")) (fst (List.split AdaptonZoo.All.a_list))
-        (list_printer task_printer) tasks;
+        (list_printer task_printer) tasks
+        units;
     exit 0
 
 let do_benchmark (module A : AdaptonUtil.Signatures.AType) ~make_input ~setup ~do_edit =
                     (print_stats_list "%d" (fun x -> (get x).dirty))
                     (print_stats_list "%d" (fun x -> (get x).clean))
             in
-            Printf.printf "{%t,\"setup\":{%a,%a},\"edits\":{\"update\":{%t},\"take\":{%t},\"edit-count\":[%t],\"max-heap\":[%t],\"max-stack\":[%t]},%s}\n%!"
+            Printf.printf "{%t,\"setup\":{%a,%a},\"edits\":{\"update\":{%t},\"take\":{%t},\"edit-count\":[%t],\"max-heap\":[%t],\"max-stack\":[%t]}}\n%!"
                 config stats setup_stats top_heap_stack setup_top_heap_stack
                 (print_stats_lists (fun ( u, _, _, _, _ ) -> u))
                 (print_stats_lists (fun ( _, t, _, _, _ ) -> t))
                 (print_stats_list "%d" (fun ( _, _, e, _, _ ) -> e))
                 (print_stats_list "%d" (fun ( _, _, _, h, _ ) -> word_bytes h))
-                (print_stats_list "%d" (fun ( _, _, _, _, s ) -> word_bytes s))
-                units;
+                (print_stats_list "%d" (fun ( _, _, _, _, s ) -> word_bytes s));
             Printf.eprintf "%t ... done (%9.2fs) %9.3gs edit %9.3gs\n%!"
                 header (get_time () -. start_time) setup_stats.time !edit_time
         end else begin
-            Printf.printf "{%t,\"setup\":{%a,%a},%s}\n%!"
-                config stats setup_stats top_heap_stack setup_top_heap_stack units;
+            Printf.printf "{%t,\"setup\":{%a,%a}}\n%!"
+                config stats setup_stats top_heap_stack setup_top_heap_stack;
             Printf.eprintf "%t ... done (%9.2fs) %9.3gs\n%!" header (get_time () -. start_time) setup_stats.time
         end
     with e ->

File Benchmarks/BenchmarkAdapton/runbenchmarkadapton.py

                         x_axis = "size"
                         x_label = ""
                     with gzip.open(os.path.join(output, "%s-%04d.json.gz" % ( task, len(results) )), "w") as jsonfile:
-                        print>>jsonfile, "{\"label\":\"%s\",\"x-axis\":\"%s\",\"x-label\":\"%s\",\"data\":[%s]}" \
-                            % ( label, x_axis, x_label, ", ".join(results) )
+                        print>>jsonfile, "{\"units\":%s,\"label\":\"%s\",\"x-axis\":\"%s\",\"x-label\":\"%s\",\"data\":[%s]}" \
+                            % ( json.dumps(config["units"]), label, x_axis, x_label, ", ".join(results) )
 
     if not args.summaries:
         sys.exit()
 
         with Tee(sys.stderr, os.path.join(output, "summary.txt"), "w") as txtfile:
             tasks = OrderedDict()
-            units = {}
             editables = set()
             for file in files:
                 label = file[:-13]
                         if not results:
                             results = more_results
                         else:
+                            if more_results["units"] != results["units"]:
+                                raise ValueError("inconsistent units in results:\nexpected: %s\ngot: %s" % ( pformat(results["units"]), pformat(more_results["units"]) ))
                             if more_results["label"] != results["label"]:
                                 raise ValueError("inconsistent label in results:\nexpected: %s\ngot: %s" % ( results["label"], more_results["label"] ))
                             if more_results["x-axis"] != results["x-axis"]:
                                 .setdefault(record[results["x-axis"]], []).append(record["setup"][key])
                             sizes.add(record["size"])
                             takes.add(record["take"])
-                        if not units:
-                            units = record["units"]
-                        elif units != record["units"]:
-                            raise ValueError("inconsistent units in results:\nexpected: %s\ngot: %s" % ( pformat(units), pformat(record["units"]) ))
                     except Exception:
                         traceback.print_exc()
                         if "error" in record:
                             htmltable.th("max-heap")
                     with htmltable.tr():
                         for _ in args.baselines:
-                            htmltable.th(units["time"])
-                            htmltable.th(units["max-heap"])
+                            htmltable.th(results["units"]["time"])
+                            htmltable.th(results["units"]["max-heap"])
                         for _ in xrange(len(editables) * 2):
-                            htmltable.th(units["time"])
+                            htmltable.th(results["units"]["time"])
                             for baseline in args.baselines:
                                 htmltable.th(baseline)
-                            htmltable.th(units["max-heap"])
+                            htmltable.th(results["units"]["max-heap"])
                 engFormatter = EngFormatter(exp0=True)
                 with htmltable.tbody():
                     for label, task in tasks.iteritems():
                                 ax = fig.add_subplot(1, 1, 1)
                                 ax.set_title(results["label"], fontsize=8)
                                 ax.set_xlabel(results["x-label"], fontsize=8)
-                                if units[measurement]:
-                                    ax.set_ylabel("%s (%s)" % ( measurement, units[measurement] ), fontsize=8)
+                                if results["units"][measurement]:
+                                    ax.set_ylabel("%s (%s)" % ( measurement, results["units"][measurement] ), fontsize=8)
                                 else:
                                     ax.set_ylabel("%s" % ( measurement, ), fontsize=8)
                                 for axis in ( ax.get_xaxis(), ax.get_yaxis() ):
                                 ax = fig.add_subplot(1, 1, 1)
                                 ax.set_title("%s details; %s" % ( module, results["label"] ), fontsize=8)
                                 ax.set_xlabel(results["x-label"], fontsize=8)
-                                ax.set_ylabel("time (%s)" % ( units["time"], ), fontsize=8)
+                                ax.set_ylabel("time (%s)" % ( results["units"]["time"], ), fontsize=8)
                                 for axis in ( ax.get_xaxis(), ax.get_yaxis() ):
                                     axis.set_major_formatter(EngFormatter())
                                     axis.set_ticks_position("none")