[libc-commits] [PATCH] D83380: [libc][benchmark] Add display option to render.py3

Andre Vieira via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 8 03:54:25 PDT 2020


avieira created this revision.
avieira added a reviewer: gchatelet.
Herald added a reviewer: lebedev.ri.
Herald added subscribers: libc-commits, ecnelises, tschuett, lebedev.ri.
Herald added a project: libc-project.

Whilst looking at the LLVM libc benchmarks I found the need to display the ‘sizes’ of the datasets against ‘bytes/cycle’ rather than ‘time’.  For this reason I added an option called ‘—display’ to enable to switch between the different modes.  This was just for some local tests, but I thought it might be useful to others upstream.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83380

Files:
  libc/benchmarks/render.py3


Index: libc/benchmarks/render.py3
===================================================================
--- libc/benchmarks/render.py3
+++ libc/benchmarks/render.py3
@@ -112,7 +112,7 @@
     return config
 
 
-def setup_graphs(files):
+def setup_graphs(files, display):
     """Setups the graphs to render from the json files."""
     jsons = []
     for file in files:
@@ -129,7 +129,13 @@
             assert len(sizes) == len(runtimes)
             values = collections.defaultdict(lambda: [])
             for i in range(len(sizes)):
-              values[sizes[i]].append(runtimes[i])
+              value = runtimes[i]
+              if display == "cycles":
+                  value = value * root["Host"]["CpuFrequency"]
+              if display == "bytespercycle":
+                  value = value * root["Host"]["CpuFrequency"]
+                  value = sizes[i] / value
+              values[sizes[i]].append(value)
             add_plot(function_name, values)
 
     config = get_configuration(jsons)
@@ -148,9 +154,15 @@
     axes.set_title(get_title(get_host(jsons)))
     axes.set_ylim(bottom=0)
     axes.set_xlabel("Size")
-    axes.set_ylabel("Time")
     axes.xaxis.set_major_formatter(EngFormatter(unit="B"))
-    axes.yaxis.set_major_formatter(EngFormatter(unit="s"))
+    if display == "cycles":
+          axes.set_ylabel("Cycles")
+    if display == "time":
+          axes.set_ylabel("Time")
+          axes.yaxis.set_major_formatter(EngFormatter(unit="s"))
+    if display == "bytespercycle":
+          axes.set_ylabel("bytes/cycle")
+          
     plt.legend()
     plt.grid()
 
@@ -164,8 +176,14 @@
         "--headless",
         help="If set do not display the graph.",
         action="store_true")
+    parser.add_argument(
+        "--display",
+        choices= ["time", "cycles", "bytespercycle"],
+        default="time",
+        help="Use to display either 'time', 'cycles' or 'bytes/cycle'.")
+
     args = parser.parse_args()
-    setup_graphs(args.files)
+    setup_graphs(args.files, args.display)
     if args.output:
         plt.savefig(args.output)
     if not args.headless:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83380.276348.patch
Type: text/x-patch
Size: 2124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200708/2ef00be8/attachment-0001.bin>


More information about the libc-commits mailing list