summaryrefslogtreecommitdiff
path: root/tools/wtperf_stats.py
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-02-10 17:18:14 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-02-10 17:18:14 +1100
commitc755e2702d55520db5ad8f6a795e4717953b5657 (patch)
tree47e9dbfeae08c090c9cfcc18ef3f93ebe2d9476c /tools/wtperf_stats.py
parentf0e125cd84e128b4e63c6db2042767450b2d50ce (diff)
downloadmongo-c755e2702d55520db5ad8f6a795e4717953b5657.tar.gz
Add a wtperf option to wtstats NVD3 graphing script.
This takes adds wtperf monitor statistics to the WiredTiger statistics plots. Assumes that the statistics file(s) are in the wtperf directory, also currently requires that --abstime argument is used.
Diffstat (limited to 'tools/wtperf_stats.py')
-rw-r--r--tools/wtperf_stats.py128
1 files changed, 76 insertions, 52 deletions
diff --git a/tools/wtperf_stats.py b/tools/wtperf_stats.py
index a35b3c7f3bd..38f164d1f63 100644
--- a/tools/wtperf_stats.py
+++ b/tools/wtperf_stats.py
@@ -26,19 +26,21 @@
# OTHER DEALINGS IN THE SOFTWARE.
#
-import csv, operator
+import os, csv, operator
from time import mktime
try:
from wt_nvd3_util import multiChart, parsetime
except ImportError:
- print >>sys.stderr, "Could not import wt_nvd3_util.py, it should be in the same directory as %s" % sys.argv[0]
+ print >>sys.stderr, "Could not import wt_nvd3_util.py, it should be\
+ in the same directory as %s" % sys.argv[0]
sys.exit(-1)
try:
from stat_data import no_scale_per_second_list
except ImportError:
- print >>sys.stderr, "Could not import stat_data.py, it should be in the same directory as %s" % sys.argv[0]
+ print >>sys.stderr, "Could not import stat_data.py, it should be in\
+ the same directory as %s" % sys.argv[0]
sys.exit(-1)
# Fixup the names and values in a dictionary read in from a csv file. One
@@ -72,54 +74,76 @@ def munge_dict(values_dict):
return ret
-# Parse the command line
-import argparse
-
-parser = argparse.ArgumentParser(description='Create graphs from WiredTiger statistics.')
-parser.add_argument('--output', '-o', metavar='file',
- default='wtperf_stats.html', help='HTML output file')
-parser.add_argument('files', metavar='file', nargs='+',
- help='input monitor file generated by WiredTiger wtperf application')
-args = parser.parse_args()
-
-output_file = open(args.output, 'w')
-
-if len(args.files) != 1:
- print 'Script currently only supports a single monitor file'
- exit (1)
-
-for f in args.files:
- with open(f, 'rb') as csvfile:
- reader = csv.DictReader(csvfile)
- # Transform the data into something NVD3 can digest
- graph_data = munge_dict(reader)
-
-chart = multiChart(name='wtperf',
- height=450 + 10*len(graph_data[0].keys()),
- resize=True,
- x_axis_format='%H:%M:%S',
- x_is_date=1,
- assets_directory='http://source.wiredtiger.com/graphs/')
-
-# Extract the times - they are the same for all lines.
-times = []
-for v in graph_data:
- times.append(v['time'])
-
-# Add a line to the graph for each field in the CSV file in alphabetical
-# order, so the key is sorted.
-for field in sorted(graph_data[0].keys()):
- if field == 'time':
- continue
- # Split the latency and non-latency measurements onto different scales
- axis = "1"
- if field.find('latency') == -1:
- axis="2"
- ydata = []
+def addPlotsToChart(chart, graph_data, wtstat_chart = False):
+ # Extract the times - they are the same for all lines.
+ times = []
for v in graph_data:
- ydata.append(v[field])
- chart.add_serie(x=times, y=ydata, name=field, type="line", yaxis=axis)
+ times.append(v['time'])
+
+ # Add a line to the graph for each field in the CSV file in alphabetical
+ # order, so the key is sorted.
+ for field in sorted(graph_data[0].keys()):
+ if field == 'time':
+ continue
+ # Split the latency and non-latency measurements onto different scales
+ axis = "1"
+ if not wtstat_chart and field.find('latency') == -1:
+ axis="2"
+ ydata = []
+ for v in graph_data:
+ ydata.append(v[field])
+ chart.add_serie(x=times, y=ydata, name=field, type="line", yaxis=axis)
+
+# Input parameters are a chart populated with WiredTiger statistics and
+# the directory where the wtperf monitor file can be found.
+def addPlotsToStatsChart(chart, dirname):
+ fname = os.path.join(dirname, 'monitor')
+ try:
+ with open(fname, 'rb') as csvfile:
+ reader = csv.DictReader(csvfile)
+ # Transform the data into something NVD3 can digest
+ graph_data = munge_dict(reader)
+ except IOError:
+ print >>sys.stderr, "Could not open wtperf monitor file."
+ sys.exit(-1)
+ addPlotsToChart(chart, graph_data, 1)
+
+def main():
+ # Parse the command line
+ import argparse
+
+ parser = argparse.ArgumentParser(description='Create graphs from WiredTiger statistics.')
+ parser.add_argument('--output', '-o', metavar='file',
+ default='wtperf_stats.html', help='HTML output file')
+ parser.add_argument('files', metavar='file', nargs='+',
+ help='input monitor file generated by WiredTiger wtperf application')
+ args = parser.parse_args()
+
+ output_file = open(args.output, 'w')
+
+ if len(args.files) != 1:
+ print 'Script currently only supports a single monitor file'
+ exit (1)
+
+ for f in args.files:
+ with open(f, 'rb') as csvfile:
+ reader = csv.DictReader(csvfile)
+ # Transform the data into something NVD3 can digest
+ graph_data = munge_dict(reader)
+
+ chart = multiChart(name='wtperf',
+ height=450 + 10*len(graph_data[0].keys()),
+ resize=True,
+ x_axis_format='%H:%M:%S',
+ x_is_date=1,
+ assets_directory='http://source.wiredtiger.com/graphs/')
+
+ addPlotsToChart(chart, graph_data)
+
+ chart.buildhtml()
+ output_file.write(chart.htmlcontent)
+ output_file.close()
+
+if __name__ == '__main__':
+ main()
-chart.buildhtml()
-output_file.write(chart.htmlcontent)
-output_file.close()