def plotScatter(scatter_data, output_path): options = { 'plottype': 'points', 'key': False, #~ 'ylabel': scatter_block[0][1], 'yformat': '%g', 'xformat': '%g', } stupidplot.gnuplotTable(scatter_data, output_path, options)
def plotAverage(average_data, output_path): options = { #~ 'plottype': 'points', #~ 'key': False, #~ 'ylabel': 'Transactions/s', 'errorbars': [1], 'yformat': '%g', 'xformat': '%g', #~ 'xrange' : "[0:]", 'yrange': "[0:]", } stupidplot.gnuplotTable(average_data, output_path, options)
def plotAverage(average_data, output_path): options = { #~ 'plottype': 'points', #~ 'key': False, #~ 'ylabel': 'Transactions/s', 'errorbars': [1], 'yformat': '%g', 'xformat': '%g', #~ 'xrange' : "[0:]", 'yrange' : "[0:]", } stupidplot.gnuplotTable(average_data, output_path, options)
def main(): if len(sys.argv) < 3: sys.stderr.write( "plot_raw.py [input file|- for stdin]+ [output prefix]\n") sys.exit(1) input_paths = sys.argv[1:-1] output_prefix = sys.argv[-1] output_throughput = output_prefix + "_thrpt.eps" output_latency = output_prefix + "_ltncy.eps" error = False for path in (output_throughput, output_latency): if os.path.exists(path): sys.stderr.write( "output path '%s' exists; please move it out of the way\n" % path) error = True if error: sys.exit(1) throughputs = [] latencies = [] for input_path in input_paths: throughput = [("time (s)", input_path)] latency = [("time (s)", input_path)] for r in CSVIterator(input_path): start = r[0] sample_average = r[1] sample_throughput = r[2] throughput.append([start, sample_throughput]) latency.append([start, sample_average]) throughputs.append(throughput) latencies.append(latency) options = { 'yformat': '%g', 'xformat': '%g', 'yrange': "[0:]", } options["ylabel"] = "Throughput (txns/s)" stupidplot.gnuplotTable(throughputs, output_throughput, options) options["ylabel"] = "Latency (us)" #~ options["yrange"] = "[:1000000]" stupidplot.gnuplotTable(latencies, output_latency, options)
def main(): if len(sys.argv) < 3: sys.stderr.write("plot_raw.py [input file|- for stdin]+ [output prefix]\n") sys.exit(1) input_paths = sys.argv[1:-1] output_prefix = sys.argv[-1] output_throughput = output_prefix + "_thrpt.eps" output_latency = output_prefix + "_ltncy.eps" error = False for path in (output_throughput, output_latency): if os.path.exists(path): sys.stderr.write("output path '%s' exists; please move it out of the way\n" % path) error = True if error: sys.exit(1) throughputs = [] latencies = [] for input_path in input_paths: throughput = [("time (s)", input_path)] latency = [("time (s)", input_path)] for r in CSVIterator(input_path): start = r[0] sample_average = r[1] sample_throughput = r[2] throughput.append([start, sample_throughput]) latency.append([start, sample_average]) throughputs.append(throughput) latencies.append(latency) options = { 'yformat': '%g', 'xformat': '%g', 'yrange' : "[0:]", } options["ylabel"] = "Throughput (txns/s)" stupidplot.gnuplotTable(throughputs, output_throughput, options) options["ylabel"] = "Latency (us)" #~ options["yrange"] = "[:1000000]" stupidplot.gnuplotTable(latencies, output_latency, options)
def plot(path): table = dataextract.readCSVTable(path) # Take only the little endian results #~ table = dataextract.select(table, [(1, "le")]) # Express buffer size in kB table = [(r[0], r[1], r[2]/1024, r[3]) for r in table] # Express throughput in GB/s #~ table = [(r[0], r[1], r[2], r[3]/1024.) for r in table] groups = dataextract.groupBy(table, [0, 1]) datasets = [] keys = groups.keys() keys.sort(labelCmp) for key in keys: data = dataextract.selectStatsConfPlot(groups[key], [2], 3) label = ("Buffer Size (kB)", "%s %s" % (LABEL_MAP[key[0]], LABEL_MAP[key[1]])) #~ label = ("Buffer Size (kB)", LABEL_MAP[key[0]]) print label data.insert(0, label) datasets.append(data) print data #~ data = dataextract.selectStatsConfPlot(table, [0, 1, 2], 3) #~ print data options = { "key": "bottom right", "errorbars": [1], "xrange": "[0:]", "yrange": "[0:]", #~ "ylabel": "Write Throughput (GB/s)", #~ "ylabel": "Fill Byte Throughput (MB/s)", "ylabel": "Fill Int Throughput (MB/s)", "xformat": "%.0f", #~ "xtics": "1024", "yformat": "%.0f", } stupidplot.gnuplotTable(datasets, "out.eps", options)
#!/usr/bin/python # An example script for the "simple.tcl" example wireless ns2 scenario # This script parses the trace file and produces a graph showing the flow # throughput over time import sys import flowanalysis import throughputOverTime import stupidplot if len( sys.argv ) != 3: print "example.py <trace file> <output eps file>" sys.exit( 1 ) input = file( sys.argv[1] ) flows = flowanalysis.parseFlowsFromTrace( input ) input.close() data = throughputOverTime.throughputOverTime( flows ) stupidplot.gnuplotTable( data, sys.argv[2] )
average = [('Simultaneous Clients', server_type, '-95% confidence', '+95% confidence')] for row in table: x = row[0] for y in row[1:]: scatter.append((x, y)) stats = statistics.stats([float(f) for f in row[1:]]) average.append( (x, stats[0], stats[0] - stats[-1], stats[0] + stats[-1])) options = { 'plottype': 'points', 'key': False, 'ylabel': scatter[0][1], } stupidplot.gnuplotTable(scatter, server_type + "-scatter.eps", options) averages.append(average) options = { #~ 'plottype': 'points', #~ 'key': False, 'ylabel': 'Messages/s', 'errorbars': [1], 'yformat': '%g', 'xformat': '%g', 'key': 'bottom right', } stupidplot.gnuplotTable(averages, "average.eps", options)
#!/usr/bin/python import csv import sys import stupidplot d = open(sys.argv[1]) samples = [] for row in csv.reader(d): assert len(row) == 1 samples.append(float(row[0])) d.close() histogram = stupidplot.histogram(samples, 16, 40000, 56000) stupidplot.gnuplotTable(histogram, "histogram.eps")
charsets = [] for r in connection.execute("select distinct charset from results"): charsets.append(r[0]) for charset in charsets: output = xaxis(c, "string_length", "chars_per_us", charset=charset) average_out = [] for table in output: average_table = [table[0]] last_x = table[1][0] sum = 0 count = 0 for row in table[1:]: if last_x != row[0]: average_table.append((last_x, sum/count)) sum = 0 count = 0 last_x = row[0] sum += row[1] count += 1 average_table.append((last_x, sum/count)) average_out.append(average_table) options = { #~ "plottype": "points", "ylabel": "UTF-16 chars per us", "key": "bottom right", } stupidplot.gnuplotTable(average_out, "stringbytebuffer-%s.eps" % charset, options)
scatter = [('Simultaneous Clients', 'Messages/s')] average = [('Simultaneous Clients', server_type, '-95% confidence', '+95% confidence')] for row in table: x = row[0] for y in row[1:]: scatter.append((x, y)) stats = statistics.stats([float(f) for f in row[1:]]) average.append((x, stats[0], stats[0]-stats[-1], stats[0]+stats[-1])) options = { 'plottype': 'points', 'key': False, 'ylabel': scatter[0][1], } stupidplot.gnuplotTable(scatter, server_type + "-scatter.eps", options) averages.append(average) options = { #~ 'plottype': 'points', #~ 'key': False, 'ylabel': 'Messages/s', 'errorbars': [1], 'yformat': '%g', 'xformat': '%g', 'key': 'bottom right', } stupidplot.gnuplotTable(averages, "average.eps", options)
paths = net.findShortestPathsHeuristic( src, dst ) length = len( paths[0] ) # Create the scenario file scriptBuilder = networks.NS2ScriptBuilder( net ) scriptBuilder.addFlow( paths[0], UDP=False ) temp = tempfile.NamedTemporaryFile() temp.write( scriptBuilder.getScript() ) temp.flush() # Run the TCP simulation pid,dataPipe = ns2stats.executeNs2( "ns %s 0" % ( temp.name ) ) # Parse the output flows = flowanalysis.parseFlowsFromTrace( dataPipe ) dataPipe.close() temp.close() data = throughputOverTime( flows ) # Graph the data options = { 'ylabel': 'Throughput (kBytes/s)', } stupidplot.gnuplotTable( data, "out.eps", options ) # Dump the network so we can draw it temp = file( "out.txt", "w" ) temp.write( net.drawScript( [ paths[0] ] ) ) temp.close()
paths = net.findShortestPathsHeuristic(src, dst) length = len(paths[0]) # Create the scenario file scriptBuilder = networks.NS2ScriptBuilder(net) scriptBuilder.addFlow(paths[0], UDP=False) temp = tempfile.NamedTemporaryFile() temp.write(scriptBuilder.getScript()) temp.flush() # Run the TCP simulation pid, dataPipe = ns2stats.executeNs2("ns %s 0" % (temp.name)) # Parse the output flows = flowanalysis.parseFlowsFromTrace(dataPipe) dataPipe.close() temp.close() data = throughputOverTime(flows) # Graph the data options = { 'ylabel': 'Throughput (kBytes/s)', } stupidplot.gnuplotTable(data, "out.eps", options) # Dump the network so we can draw it temp = file("out.txt", "w") temp.write(net.drawScript([paths[0]])) temp.close()