Skip to content

Commit

Permalink
added a --tag
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed May 4, 2017
1 parent a768958 commit edd539b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
17 changes: 12 additions & 5 deletions benchpress/visualizer/cli_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ def visualize(args):

# First we create `means` which map a command label and date to a pair of mean and standard deviation
# e.g. means['Bean']['2017-05-02 13:29:34.87'] = (0.1289, 0.0006)
(means, cmd_labels, creation_dates) = util.means_series_map(args)
(means, cmd_labels, meta_keys) = util.means_series_map(args)

# Then we write the data
ret = "Label%s " % args.csv_separator
for creation_date in creation_dates:
ret += "%s%s " % (creation_date, args.csv_separator)
for meta_key in meta_keys:
ret += "%s%s " % (meta_key, args.csv_separator)
for cmd_label in cmd_labels:
ret += "\n%s%s " % (cmd_label, args.csv_separator)
for creation_date in creation_dates:
(mean, std) = means[cmd_label].get(creation_date, (0, 0))
for meta_key in meta_keys:
(mean, std) = means[cmd_label].get(meta_key, (0, 0))
ret += "%.4f (%.4f)%s " % (mean, std, args.csv_separator)
return ret

Expand All @@ -33,6 +33,13 @@ def main():
metavar="sep",
help="Use the CSV format using 'sep' as the separator."
)
parser.add_argument(
'--meta-key',
default='creation_date_utc',
type=str,
choices=['creation_date_utc', 'tag'],
help="The meta key, which value vary throughout the series"
)
args = parser.parse_args()
if args.output is not None:
args.output.write(visualize(args))
Expand Down
17 changes: 12 additions & 5 deletions benchpress/visualizer/series_per_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def line_per_cmd(args):

# First we create `means` which map a command label and date to a pair of mean and standard deviation
# e.g. means['Bean']['2017-05-02 13:29:34.87'] = (0.1289, 0.0006)
(means, cmd_labels, creation_dates) = util.means_series_map(args)
(means, cmd_labels, meta_keys) = util.means_series_map(args)

# Let's write a plot line for each command label
fig, ax = plt.subplots()
lines = []
for cmd_label in cmd_labels:
x, y, err = ([], [], [])
for i in range(len(creation_dates)):
(mean, std) = means[cmd_label].get(creation_dates[i], (0, 0))
for i in range(len(meta_keys)):
(mean, std) = means[cmd_label].get(meta_keys[i], (0, 0))
x.append(i)
y.append(mean)
err.append(std)
Expand All @@ -40,8 +40,8 @@ def line_per_cmd(args):
plt.title(util.texsafe(args.title))

# Add some text for labels, title and axes ticks
ax.set_xticks(range(len(creation_dates)))
ax.set_xticklabels(creation_dates, rotation=args.xticklabel_rotation)
ax.set_xticks(range(len(meta_keys)))
ax.set_xticklabels(meta_keys, rotation=args.xticklabel_rotation)

if not args.no_legend:
ax.legend(lines, cmd_labels, loc='best', fancybox=True, shadow=True)
Expand Down Expand Up @@ -132,6 +132,13 @@ def main():
choices=plt.style.available,
help="The matplotlib.pyplot.style to use"
)
parser.add_argument(
'--meta-key',
default='creation_date_utc',
type=str,
choices=['creation_date_utc', 'tag'],
help="The meta key, which value vary throughout the series"
)
parser.add_argument(
'--mpld3',
action='store_true',
Expand Down
16 changes: 8 additions & 8 deletions benchpress/visualizer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def texsafe(text):


def means_series_map(args):
"""Create a dict that map a command label and date to a pair of mean and standard deviation
"""Create a dict that map a command label and meta-key to a pair of mean and standard deviation
Such as means['Bean']['2017-05-02 13:29:34.87'] = (0.1289, 0.0006)
Expand All @@ -296,17 +296,17 @@ def means_series_map(args):
The dict that maps command label and date to a pair of mean and standard deviation
cmd_labels : list
List of commands labels found in `args`
creation_dates : list
List of creation dates found in `args`
meta-keys : list
List of meta key values found in `args`
"""
# First we create `means` which map a command label and date to a pair of mean and standard deviation
# e.g. means['Bean']['2017-05-02 13:29:34.87'] = (0.1289, 0.0006)
means = {}
cmd_labels = set()
creation_dates = set()
meta_keys = set()
for result in args.results:
suite = json.load(result)
creation_date = suite['creation_date_utc']
meta_key = suite[args.meta_key]
cmd_list = suite['cmd_list']
cmd_list = filter_cmd_list(cmd_list, args.labels_to_include, args.labels_to_exclude)
for cmd in cmd_list:
Expand All @@ -315,7 +315,7 @@ def means_series_map(args):
std = standard_deviation(succeed_values)
if cmd['label'] not in means:
means[cmd['label']] = {}
means[cmd['label']][creation_date] = (avg, std)
means[cmd['label']][meta_key] = (avg, std)
cmd_labels.add(cmd['label'])
creation_dates.add(creation_date)
return (means, sorted(list(cmd_labels)), sorted(list(creation_dates)))
meta_keys.add(meta_key)
return (means, sorted(list(cmd_labels)), sorted(list(meta_keys)))

0 comments on commit edd539b

Please sign in to comment.