Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config options to handle custom graphs' width and height in reports #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions multimechanize/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


# response time graph for raw data
def resp_graph_raw(nested_resp_list, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
def resp_graph_raw(nested_resp_list, image_name, graph_width, graph_height, dir='./'):
fig = figure(figsize=(graph_width, graph_height)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Response Time (secs)' , size='x-small')
Expand All @@ -38,8 +38,8 @@ def resp_graph_raw(nested_resp_list, image_name, dir='./'):


# response time graph for bucketed data
def resp_graph(avg_resptime_points_dict, percentile_80_resptime_points_dict, percentile_90_resptime_points_dict, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
def resp_graph(avg_resptime_points_dict, percentile_80_resptime_points_dict, percentile_90_resptime_points_dict, image_name, graph_width, graph_height, dir='./'):
fig = figure(figsize=(graph_width, graph_height)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Response Time (secs)' , size='x-small')
Expand Down Expand Up @@ -82,8 +82,8 @@ def resp_graph(avg_resptime_points_dict, percentile_80_resptime_points_dict, per


# throughput graph
def tp_graph(throughputs_dict, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
def tp_graph(throughputs_dict, image_name, graph_width, graph_height, dir='./'):
fig = figure(figsize=(graph_width, graph_height)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Transactions Per Second (count)' , size='x-small')
Expand Down
16 changes: 8 additions & 8 deletions multimechanize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@



def output_results(results_dir, results_file, run_time, rampup, ts_interval, user_group_configs=None, xml_reports=False):
def output_results(results_dir, results_file, run_time, rampup, ts_interval, graph_width, graph_height, user_group_configs=None, xml_reports=False):
results = Results(results_dir + results_file, run_time)

report = reportwriter.Report(results_dir)
Expand Down Expand Up @@ -62,7 +62,7 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use
t = (resp_stats.elapsed_time, resp_stats.trans_time)
trans_timer_points.append(t)
trans_timer_vals.append(resp_stats.trans_time)
graph.resp_graph_raw(trans_timer_points, 'All_Transactions_response_times.png', results_dir)
graph.resp_graph_raw(trans_timer_points, 'All_Transactions_response_times.png', graph_width, graph_height, results_dir)

report.write_line('<h3>Transaction Response Summary (secs)</h3>')
report.write_line('<table>')
Expand Down Expand Up @@ -111,7 +111,7 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use
percentile_90_resptime_points[interval_start] = pct_90

report.write_line('</table>')
graph.resp_graph(avg_resptime_points, percentile_80_resptime_points, percentile_90_resptime_points, 'All_Transactions_response_times_intervals.png', results_dir)
graph.resp_graph(avg_resptime_points, percentile_80_resptime_points, percentile_90_resptime_points, 'All_Transactions_response_times_intervals.png', graph_width, graph_height, results_dir)


report.write_line('<h3>Graphs</h3>')
Expand All @@ -130,7 +130,7 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use
splat_series = split_series(trans_timer_points, interval_secs)
for i, bucket in enumerate(splat_series):
throughput_points[int((i + 1) * interval_secs)] = (len(bucket) / interval_secs)
graph.tp_graph(throughput_points, 'All_Transactions_throughput.png', results_dir)
graph.tp_graph(throughput_points, 'All_Transactions_throughput.png', graph_width, graph_height, results_dir)



Expand All @@ -145,14 +145,14 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use
custom_timer_vals.append(val)
except KeyError:
pass
graph.resp_graph_raw(custom_timer_points, timer_name + '_response_times.png', results_dir)
graph.resp_graph_raw(custom_timer_points, timer_name + '_response_times.png', graph_width, graph_height, results_dir)

throughput_points = {} # {intervalnumber: numberofrequests}
interval_secs = ts_interval
splat_series = split_series(custom_timer_points, interval_secs)
for i, bucket in enumerate(splat_series):
throughput_points[int((i + 1) * interval_secs)] = (len(bucket) / interval_secs)
graph.tp_graph(throughput_points, timer_name + '_throughput.png', results_dir)
graph.tp_graph(throughput_points, timer_name + '_throughput.png', graph_width, graph_height, results_dir)

report.write_line('<hr />')
report.write_line('<h2>Custom Timer: %s</h2>' % timer_name)
Expand Down Expand Up @@ -205,7 +205,7 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use
percentile_80_resptime_points[interval_start] = pct_80
percentile_90_resptime_points[interval_start] = pct_90
report.write_line('</table>')
graph.resp_graph(avg_resptime_points, percentile_80_resptime_points, percentile_90_resptime_points, timer_name + '_response_times_intervals.png', results_dir)
graph.resp_graph(avg_resptime_points, percentile_80_resptime_points, percentile_90_resptime_points, timer_name + '_response_times_intervals.png', graph_width, graph_height, results_dir)


report.write_line('<h3>Graphs</h3>')
Expand Down Expand Up @@ -350,4 +350,4 @@ def percentile(seq, percentile):


if __name__ == '__main__':
output_results('./', 'results.csv', 60, 30, 10)
output_results('./', 'results.csv', 60, 30, 10, 8, 3.3)
4 changes: 4 additions & 0 deletions multimechanize/utilities/newproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
console_logging = off
xml_report = off

[reporting]
graph_width = 8
graph_height = 3.3


[user_group-1]
threads = 3
Expand Down
21 changes: 15 additions & 6 deletions multimechanize/utilities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run_test(project_name, cmd_opts, remote_starter=None):
remote_starter.test_running = True
remote_starter.output_dir = None

run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs = configure(project_name, cmd_opts)
run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, graph_width, graph_height, user_group_configs = configure(project_name, cmd_opts)

run_localtime = time.localtime()
output_dir = '%s/%s/results/results_%s' % (cmd_opts.projects_dir, project_name, time.strftime('%Y.%m.%d_%H.%M.%S/', run_localtime))
Expand Down Expand Up @@ -136,7 +136,7 @@ def run_test(project_name, cmd_opts, remote_starter=None):
# all agents are done running at this point
time.sleep(.2) # make sure the writer queue is flushed
print '\n\nanalyzing results...\n'
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, user_group_configs, xml_report)
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, graph_width, graph_height, user_group_configs, xml_report)
print 'created: %sresults.html\n' % output_dir
if xml_report:
print 'created: %sresults.jtl' % output_dir
Expand All @@ -151,7 +151,7 @@ def run_test(project_name, cmd_opts, remote_starter=None):
print 'loading results into database: %s\n' % results_database
import multimechanize.resultsloader
multimechanize.resultsloader.load_results_database(project_name, run_localtime, output_dir, results_database,
run_time, rampup, results_ts_interval, user_group_configs)
run_time, rampup, results_ts_interval, graph_width, graph_height, user_group_configs)

if post_run_script is not None:
print 'running post_run_script: %s\n' % post_run_script
Expand All @@ -170,9 +170,9 @@ def run_test(project_name, cmd_opts, remote_starter=None):
def rerun_results(project_name, cmd_opts, results_dir):
output_dir = '%s/%s/results/%s/' % (cmd_opts.projects_dir, project_name, results_dir)
saved_config = '%s/config.cfg' % output_dir
run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs = configure(project_name, cmd_opts, config_file=saved_config)
run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, graph_width, graph_height, user_group_configs = configure(project_name, cmd_opts, config_file=saved_config)
print '\n\nanalyzing results...\n'
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, user_group_configs, xml_report)
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, graph_width, graph_height, user_group_configs, xml_report)
print 'created: %sresults.html\n' % output_dir
if xml_report:
print 'created: %sresults.jtl' % output_dir
Expand Down Expand Up @@ -213,14 +213,23 @@ def configure(project_name, cmd_opts, config_file=None):
xml_report = config.getboolean(section, 'xml_report')
except ConfigParser.NoOptionError:
xml_report = False
elif section == 'reporting':
try:
graph_width = config.getfloat(section, 'graph_width')
except ConfigParser.NoOptionError:
graph_width = 8
try:
graph_height = config.getfloat(section, 'graph_height')
except ConfigParser.NoOptionError:
graph_height = 3.3
else:
threads = config.getint(section, 'threads')
script = config.get(section, 'script')
user_group_name = section
ug_config = UserGroupConfig(threads, user_group_name, script)
user_group_configs.append(ug_config)

return (run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs)
return (run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, graph_width, graph_height, user_group_configs)



Expand Down