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

Added support for custom fields #28

Open
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion multimechanize/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ def run(self):

epoch = time.mktime(time.localtime())

fields = (elapsed, epoch, self.user_group_name, scriptrun_time, error, trans.custom_timers)
fields = (elapsed, epoch, self.user_group_name, scriptrun_time, error, trans.custom_timers, getattr(trans, 'custom_fields', {}))
self.queue.put(fields)
8 changes: 5 additions & 3 deletions multimechanize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import graph
import reportwriter
import reportwriterxml

import re


def output_results(results_dir, results_file, run_time, rampup, ts_interval, user_group_configs=None, xml_reports=False):
Expand Down Expand Up @@ -261,7 +261,7 @@ def __parse_file(self):
f = open(self.results_file_name, 'rb')
resp_stats_list = []
for line in f:
fields = line.strip().split(',')
fields = line.strip().split(',', 6)

request_num = int(fields[0])
elapsed_time = float(fields[1])
Expand All @@ -272,8 +272,10 @@ def __parse_file(self):

self.uniq_user_group_names.add(user_group_name)


custom_timers = {}
timers_string = ''.join(fields[6:]).replace('{', '').replace('}', '')
custom_fields_string, timers_string = re.match("(.*\\{.*?\\}.*),(.*)", fields[6]).groups()
timers_string = timers_string.replace("{", "").replace("}", "")
splat = timers_string.split("'")[1:]
timers = []
vals = []
Expand Down
6 changes: 3 additions & 3 deletions multimechanize/resultswriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def run(self):
with open(self.output_dir + 'results.csv', 'w') as f:
while True:
try:
elapsed, epoch, self.user_group_name, scriptrun_time, error, custom_timers = self.queue.get(False)
elapsed, epoch, self.user_group_name, scriptrun_time, error, custom_timers, custom_fields = self.queue.get(False)
self.trans_count += 1
self.timer_count += len(custom_timers)
if error != '':
# Convert line breaks to literal \n so the CSV will be readable.
error = '\\n'.join(error.splitlines())

self.error_count += 1
f.write('%i,%.3f,%i,%s,%f,%s,%s\n' % (self.trans_count, elapsed, epoch, self.user_group_name, scriptrun_time, error, repr(custom_timers)))
f.write('%i,%.3f,%i,%s,%f,%s,%r,%r\n' % (self.trans_count, elapsed, epoch, self.user_group_name, scriptrun_time, error, custom_fields, custom_timers))
f.flush()
if self.console_logging:
print '%i, %.3f, %i, %s, %.3f, %s, %s' % (self.trans_count, elapsed, epoch, self.user_group_name, scriptrun_time, error, repr(custom_timers))
print '%i, %.3f, %i, %s, %.3f, %s, %r, %r' % (self.trans_count, elapsed, epoch, self.user_group_name, scriptrun_time, error, custom_fields, custom_timers)
except Queue.Empty:
time.sleep(.05)