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