예제 #1
0
    plot_xlabel = util.getJobName(cur, xjob) + " ("+ str(xjob) + ")"
    plot_ylabel = util.getJobName(cur, yjob) + " ("+ str(yjob) + ")"
    plot_title = plot_xlabel + " vs " + plot_ylabel
    
    data_file = open(data_file_name, 'w')
    javascript_file = open(javascript_file_name, 'w')
    gnuplot_command = cStringIO.StringIO()
    
    util.setupPlot(gnuplot_command, plot_xlabel, plot_ylabel, plot_title)
    util.setupCanvasPlot(gnuplot_command, "gnuplot_canvas")

    util.startPlot(gnuplot_command)

    results_and_answers = util.getRunTimesAndAnswer(cur, xjob, yjob)
    results = filterUnknowns(results_and_answers)
    families = util.groupByFamilies(results)
    if input_family == None or input_family == "":
	run_over_families = families
    else:
	if input_family[0] == '-':
 		input_family = input_family[1:]
		exclude_families = input_family.split(',')
		run_over_families = [item for item in families if item not in exclude_families]
        else:
	        run_over_families = input_family.split(',')
    
    util.declareJavaScriptArrays(javascript_file);
    for family in run_over_families:
        family_results = families[family]
        util.dumpFamilyToFile(data_file, family, family_results)
        util.dumpJavaScriptArray(javascript_file, family_results)
        family_results = families[family]
        dumpResultsToFiles(data_file, jsmap_file, family, family_results)
        sys.stdout.write("\"< cat "+data_name+"\" index " + str(i) +" using 2:3 with points pt 9 pointsize 1 linecolor " + str(i) + ", ")
        i = i + 1
    sys.stdout.write("x with line linecolor rgb \"gray\" \n")
    data_file.close()
    jsmap_file.close()

def setupGnuPlot(title, xlabel, ylabel) :
    sys.stdout.write("set autoscale\n")
    sys.stdout.write("set title \"" + title + "\"\n")
    sys.stdout.write("set xlabel \"" + xlabel + "\"\n")
    sys.stdout.write("set ylabel \"" + ylabel + "\"\n")
    sys.stdout.write("set xtic auto\n")
    sys.stdout.write("set ytic auto\n")
    sys.stdout.write("set terminal canvas size 800, 600 name \"gnuplot_canvas\"\n")
    sys.stdout.write("set key outside autotitle columnheader\n")
    
con = mdb.connect(server, user, password, table);
with con:
    cur = con.cursor()
    plot_title = pu.getJobName(cur, xjob) + " vs " + pu.getJobName(cur, yjob)
    plot_xlabel = "time " + pu.getJobName(cur, xjob)
    plot_ylabel = "time " + pu.getJobName(cur, yjob)

    results = getResults(cur, xjob, yjob)
    families = pu.groupByFamilies(results)
    setupGnuPlot(plot_title, plot_xlabel, plot_ylabel)
    generatePlots(data_file, js_map_file, families)
con.close()