tools/performance/memtest/cgi/memtest_form.cgi

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/usr/bin/perl
michael@0 2 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6
michael@0 7 #______________________________________________________________________________________
michael@0 8 # these variables will need to be changed to fit the host machine configuration/directories.
michael@0 9 #
michael@0 10 # this is where the linux.dat files live; currently /home/usr/ftp/pub/data/memtests
michael@0 11 $directory_root = "/u/twalker/memtest/results/daily";
michael@0 12 #
michael@0 13 $host_server = "smoketest1";
michael@0 14 #
michael@0 15 # note: the /plots_tmp directory under $results_dir will need to be cleaned out periodically
michael@0 16 # because this is where the .png files will be put on creation (it could become a memory hog)
michael@0 17 $results_dir = "/usr/local/apache/htdocs";
michael@0 18
michael@0 19 # this is where gnuplot app lives
michael@0 20 $gnuplot = "/usr/bin/gnuplot";
michael@0 21 #
michael@0 22 #--------------------------------------------------------------------------------------
michael@0 23
michael@0 24 # take in form info and convert it to usable variables --------------------------------
michael@0 25
michael@0 26 $query_string = $ENV{'QUERY_STRING'};
michael@0 27
michael@0 28 @key_value_pairs = split (/&/, $query_string);
michael@0 29
michael@0 30 foreach $key_value (@key_value_pairs)
michael@0 31 {
michael@0 32 ($key, $value) = split (/=/, $key_value);
michael@0 33 $value =~ tr/+/ /;
michael@0 34 $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
michael@0 35 $form_data{$key} = $value;
michael@0 36 @list_keys = keys(%form_data);
michael@0 37 @values_keys = values(%form_data);
michael@0 38 }
michael@0 39
michael@0 40 # error check for user selecting all three fields ------------------------------------
michael@0 41
michael@0 42 $number_of_values = @key_value_pairs;
michael@0 43
michael@0 44 if ($number_of_values != 3) {
michael@0 45 print "Content-type: text/html", "\n\n";
michael@0 46
michael@0 47 print "<HTML>", "\n";
michael@0 48 print "<HEAD><TITLE>Plotting Error</TITLE><HEAD>", "\n";
michael@0 49 print "<BODY>", "\n";
michael@0 50 print "<H1>", "Plotting Error", "</H1>", "<HR>", "\n";
michael@0 51 print "Please close this window and make a selection from each of the three fields.", "\n";
michael@0 52 print "</BODY></HTML>", "\n";
michael@0 53 }
michael@0 54
michael@0 55 # create variables to point to directories containg the linux.dat files ---------------
michael@0 56
michael@0 57 else {
michael@0 58 ($month, $day, $year) = split (/\//, $form_data{"first_date"});
michael@0 59 $first_date = "$year$month$day";
michael@0 60 ($month, $day, $year) = split (/\//, $form_data{"compare_date"});
michael@0 61 $compare_date = "$year$month$day";
michael@0 62 $test_list_in = $form_data{"test_list"};
michael@0 63 if ($test_list_in eq "large to small") {
michael@0 64 $test_list = "static41x3_gtol";
michael@0 65 }
michael@0 66 elsif ($test_list_in eq "small to large") {
michael@0 67 $test_list = "static41x3_ltog";
michael@0 68 }
michael@0 69 elsif ($test_list_in eq "plain text") {
michael@0 70 $test_list = "static_vanillaX100";
michael@0 71 }
michael@0 72 elsif ($test_list_in eq "memory hog") {
michael@0 73 $test_list = "static_iplanetX100";
michael@0 74 }
michael@0 75
michael@0 76 open(FIRST_DATE_DIR,"$directory_root/$test_list/$first_date/linux.dat") || die "could not create directory\n";
michael@0 77 open(COMPARE_DATE_DIR,"$directory_root/$test_list/$compare_date/linux.dat") || die "could not create directory\n";
michael@0 78 $first_date_dir = join ("/",$directory_root , $test_list, $first_date, "linux.dat");
michael@0 79 $compare_date_dir = join ("/", $directory_root, $test_list, $compare_date, "linux.dat");
michael@0 80
michael@0 81 # get slope of first date line---------------------------------------------------------
michael@0 82
michael@0 83 while (<FIRST_DATE_DIR>) {
michael@0 84 $line = $_;
michael@0 85 }
michael@0 86 @slope_array_first = split (' ',$line);
michael@0 87 $slope_first = $slope_array_first[1];
michael@0 88 $label_placement_first = $slope_array_first[5];
michael@0 89 $line_formula_first = join (" ", $slope_array_first[3], $slope_array_first[2], $slope_array_first[1], $slope_array_first[4], $slope_array_first[5]);
michael@0 90 chop($slope_first);chop($slope_first);chop($slope_first);
michael@0 91 close (FIRST_DATE_DIR);
michael@0 92
michael@0 93 # get slope of compare date line---------------------------------------------------------
michael@0 94
michael@0 95 while (<COMPARE_DATE_DIR>) {
michael@0 96 $line = $_;
michael@0 97 }
michael@0 98 @slope_array_compare = split (' ',$line);
michael@0 99 $slope_compare = $slope_array_compare[1];
michael@0 100 $label_placement_compare = $slope_array_compare[5];
michael@0 101 $line_formula_compare = join (" ", $slope_array_compare[3], $slope_array_compare[2], $slope_array_compare[1], $slope_array_compare[4], $slope_array_compare[5]);
michael@0 102 chop($slope_compare);chop($slope_compare);chop($slope_compare);
michael@0 103 close(COMPARE_DATE_DIR);
michael@0 104
michael@0 105 # generate gnuplot graph --------------------------------------------------------------
michael@0 106
michael@0 107 $process_id = $$;
michael@0 108 $output_file = join ("", $results_dir, "/plots_tmp/", $process_id, ".png");
michael@0 109 $output_location = join ("", "http://", $host_server, "/plots_tmp/", $process_id, ".png");
michael@0 110 open(GNUPLOT, "|$gnuplot");
michael@0 111 print GNUPLOT <<gnuplot_Commands_Done;
michael@0 112
michael@0 113 set term png color
michael@0 114 set output '$output_file'
michael@0 115 set title 'Gross Dynamic Footprints of $test_list_in list on $form_data{"first_date"} and $form_data{"compare_date"}'
michael@0 116 set xlabel 'URLs'
michael@0 117 set ylabel 'KB'
michael@0 118 set key bottom right Right title 'Legend' box -1
michael@0 119 set label '$slope_first KB/URL' at 5, $label_placement_first right rotate
michael@0 120 set label '$slope_compare KB/URL' at 10, $label_placement_compare right rotate
michael@0 121 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
michael@0 122
michael@0 123 gnuplot_Commands_Done
michael@0 124
michael@0 125 close(GNUPLOT);
michael@0 126
michael@0 127 # send graph to users browser----------------------------------------------------------
michael@0 128
michael@0 129 print "Location: $output_location", "\n\n";
michael@0 130
michael@0 131 }
michael@0 132 #end if
michael@0 133
michael@0 134 exit (0);
michael@0 135
michael@0 136
michael@0 137
michael@0 138
michael@0 139
michael@0 140
michael@0 141
michael@0 142
michael@0 143
michael@0 144
michael@0 145
michael@0 146

mercurial