tools/performance/memtest/cgi/memtest_form.cgi

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/performance/memtest/cgi/memtest_form.cgi	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,146 @@
     1.4 +#!/usr/bin/perl
     1.5 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +
     1.9 +
    1.10 +#______________________________________________________________________________________
    1.11 +# these variables will need to be changed to fit the host machine configuration/directories.
    1.12 +#
    1.13 +# this is where the linux.dat files live;  currently /home/usr/ftp/pub/data/memtests
    1.14 +    $directory_root = "/u/twalker/memtest/results/daily";
    1.15 +#
    1.16 +    $host_server = "smoketest1";
    1.17 +#
    1.18 +# note: the /plots_tmp directory under $results_dir will need to be cleaned out periodically
    1.19 +# because this is where the .png files will be put on creation (it could become a memory hog)
    1.20 +    $results_dir = "/usr/local/apache/htdocs";
    1.21 +
    1.22 +# this is where gnuplot app lives
    1.23 +    $gnuplot = "/usr/bin/gnuplot";
    1.24 +#
    1.25 +#--------------------------------------------------------------------------------------
    1.26 +
    1.27 +# take in form info and convert it to usable variables --------------------------------
    1.28 +   
    1.29 +$query_string = $ENV{'QUERY_STRING'};
    1.30 +
    1.31 +@key_value_pairs = split (/&/, $query_string);
    1.32 +
    1.33 +foreach $key_value (@key_value_pairs)
    1.34 +   {       
    1.35 +   ($key, $value) = split (/=/, $key_value);
    1.36 +   $value =~ tr/+/ /;
    1.37 +   $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
    1.38 +   $form_data{$key} = $value;
    1.39 +   @list_keys = keys(%form_data);
    1.40 +   @values_keys = values(%form_data);
    1.41 +   }
    1.42 +
    1.43 +# error check for user selecting all three fields ------------------------------------
    1.44 +
    1.45 +$number_of_values = @key_value_pairs;
    1.46 + 
    1.47 +if ($number_of_values != 3) {
    1.48 +    print "Content-type: text/html", "\n\n";
    1.49 +
    1.50 +    print "<HTML>", "\n";
    1.51 +    print "<HEAD><TITLE>Plotting Error</TITLE><HEAD>", "\n";
    1.52 +    print "<BODY>", "\n";
    1.53 +    print "<H1>", "Plotting Error", "</H1>", "<HR>", "\n";
    1.54 +    print "Please close this window and make a selection from each of the three fields.", "\n";
    1.55 +    print "</BODY></HTML>", "\n";
    1.56 +    }
    1.57 +
    1.58 +# create variables to point to directories containg the linux.dat files ---------------
    1.59 +
    1.60 +else {
    1.61 +    ($month, $day, $year) = split (/\//, $form_data{"first_date"});
    1.62 +    $first_date = "$year$month$day";
    1.63 +    ($month, $day, $year) = split (/\//, $form_data{"compare_date"});
    1.64 +    $compare_date = "$year$month$day";
    1.65 +    $test_list_in = $form_data{"test_list"};
    1.66 +    if ($test_list_in eq "large to small") {
    1.67 +	$test_list = "static41x3_gtol";
    1.68 +        }
    1.69 +    elsif ($test_list_in eq "small to large") {
    1.70 +	$test_list = "static41x3_ltog";
    1.71 +        }
    1.72 +    elsif ($test_list_in eq "plain text") {
    1.73 +	$test_list = "static_vanillaX100";
    1.74 +        }
    1.75 +    elsif ($test_list_in eq "memory hog") {
    1.76 +	$test_list = "static_iplanetX100";
    1.77 +        }
    1.78 +
    1.79 +    open(FIRST_DATE_DIR,"$directory_root/$test_list/$first_date/linux.dat") || die "could not create directory\n";
    1.80 +    open(COMPARE_DATE_DIR,"$directory_root/$test_list/$compare_date/linux.dat") || die "could not create directory\n";
    1.81 +    $first_date_dir = join ("/",$directory_root , $test_list, $first_date, "linux.dat");
    1.82 +    $compare_date_dir = join ("/", $directory_root, $test_list, $compare_date, "linux.dat"); 
    1.83 +
    1.84 +# get slope of first date line---------------------------------------------------------
    1.85 +
    1.86 +    while (<FIRST_DATE_DIR>) { 
    1.87 +	$line = $_;
    1.88 +        }
    1.89 +    @slope_array_first = split (' ',$line);
    1.90 +    $slope_first = $slope_array_first[1];
    1.91 +    $label_placement_first = $slope_array_first[5];
    1.92 +    $line_formula_first = join (" ", $slope_array_first[3], $slope_array_first[2], $slope_array_first[1], $slope_array_first[4], $slope_array_first[5]);
    1.93 +    chop($slope_first);chop($slope_first);chop($slope_first);
    1.94 +    close (FIRST_DATE_DIR);
    1.95 +
    1.96 +# get slope of compare date line---------------------------------------------------------
    1.97 +
    1.98 +    while (<COMPARE_DATE_DIR>) { 
    1.99 +	$line = $_;
   1.100 +        }
   1.101 +    @slope_array_compare = split (' ',$line);
   1.102 +    $slope_compare = $slope_array_compare[1];
   1.103 +    $label_placement_compare = $slope_array_compare[5];
   1.104 +    $line_formula_compare = join (" ", $slope_array_compare[3], $slope_array_compare[2], $slope_array_compare[1], $slope_array_compare[4], $slope_array_compare[5]);
   1.105 +    chop($slope_compare);chop($slope_compare);chop($slope_compare); 
   1.106 +    close(COMPARE_DATE_DIR);
   1.107 +
   1.108 +# generate gnuplot graph --------------------------------------------------------------
   1.109 +
   1.110 +    $process_id = $$;
   1.111 +    $output_file = join ("", $results_dir, "/plots_tmp/", $process_id, ".png");
   1.112 +    $output_location = join ("", "http://", $host_server, "/plots_tmp/", $process_id, ".png");
   1.113 +    open(GNUPLOT, "|$gnuplot");
   1.114 +    print GNUPLOT <<gnuplot_Commands_Done;
   1.115 +
   1.116 +    set term png color
   1.117 +    set output '$output_file'
   1.118 +    set title 'Gross Dynamic Footprints of $test_list_in list on $form_data{"first_date"} and $form_data{"compare_date"}'
   1.119 +    set xlabel 'URLs'
   1.120 +    set ylabel 'KB'
   1.121 +    set key bottom right Right title 'Legend' box -1
   1.122 +    set label '$slope_first KB/URL' at 5, $label_placement_first right rotate
   1.123 +    set label '$slope_compare KB/URL' at 10, $label_placement_compare right rotate
   1.124 +    plot "$compare_date_dir" using 1:2 title "VM size on $form_data{"compare_date"}" with line 1,$line_formula_compare title "Slope of $form_data{"compare_date"}" with line 7,"$first_date_dir" using 1:2 title "VM size on $form_data{"first_date"}" with line 3,$line_formula_first title "Slope of $form_data{"first_date"}" with line 9,"$compare_date_dir" using 1:4 title "Code size on $form_data{"compare_date"}" with line 2,"$first_date_dir" using 1:4 title "Code size on $form_data{"first_date"}" with line 8
   1.125 +      
   1.126 +gnuplot_Commands_Done
   1.127 +
   1.128 +    close(GNUPLOT);
   1.129 +
   1.130 +# send graph to users browser----------------------------------------------------------
   1.131 +
   1.132 +    print "Location: $output_location", "\n\n";
   1.133 +
   1.134 +    }
   1.135 +#end if
   1.136 +
   1.137 +exit (0);
   1.138 +
   1.139 +
   1.140 +
   1.141 +
   1.142 +
   1.143 +
   1.144 +
   1.145 +
   1.146 +
   1.147 +
   1.148 +
   1.149 +

mercurial