Skip to content

Commit

Permalink
grapher: row_per_script now writes the html to file
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Feb 23, 2017
1 parent 3b25a2a commit 06c765f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions module/benchpress/grapher/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def __init__(self, args):
def render(self):
raise NotImplementedError()

def tofile(self, name, source):
""" Write 'source' to a file named 'name', which should include the extension (e.g. .html or .txt).
The output directory is taken from self.args.output_path """

fname = os.path.join(self.args.output_path, name)
with open(fname, 'w') as f:
f.write(source)

class Graph(Grapher):
"""
Expand Down
6 changes: 3 additions & 3 deletions module/benchpress/grapher/row_per_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from benchpress import result_parser
from graph import Graph, filter_list, translate_dict
from graph import Grapher, filter_list, translate_dict
import json
import re

Expand All @@ -13,7 +13,7 @@ def get_stack_name(stack):
return ret[:-1]


class Row_per_script(Graph):
class Row_per_script(Grapher):

def render(self):

Expand Down Expand Up @@ -130,4 +130,4 @@ def render(self):

doc = doc.replace("__TABLE__", table)
doc = doc.replace("__TITLE__", self.args.title)
print doc
self.tofile("%s.html"%self.args.title, doc)

0 comments on commit 06c765f

Please sign in to comment.