[llvm-commits] CVS: nightlytest-serverside/NightlyTester.php
Patrick Jenkins
pjenkins at apple.com
Wed Aug 2 15:10:36 PDT 2006
Changes in directory nightlytest-serverside:
NightlyTester.php updated: 1.12 -> 1.13
---
Log message:
Added several functions to return arrays with file size information.
---
Diffs of the changes: (+168 -92)
NightlyTester.php | 260 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 168 insertions(+), 92 deletions(-)
Index: nightlytest-serverside/NightlyTester.php
diff -u nightlytest-serverside/NightlyTester.php:1.12 nightlytest-serverside/NightlyTester.php:1.13
--- nightlytest-serverside/NightlyTester.php:1.12 Tue Aug 1 19:00:09 2006
+++ nightlytest-serverside/NightlyTester.php Wed Aug 2 17:10:20 2006
@@ -20,11 +20,11 @@
*
*****************************************************/
function getMachineInfo($machine_id, $mysql_link){
- $query="SELECT * FROM machine WHERE id=$machine_id";
- $machine_query = mysql_query($query, $mysql_link) or die ("$night failed! " . mysql_error());
- $row = mysql_fetch_array($machine_query);
- mysql_free_result($machine_query);
- return $row;
+ $query="SELECT * FROM machine WHERE id=$machine_id";
+ $machine_query = mysql_query($query, $mysql_link) or die ("$night failed! " . mysql_error());
+ $row = mysql_fetch_array($machine_query);
+ mysql_free_result($machine_query);
+ return $row;
}
/*****************************************************
@@ -35,8 +35,8 @@
*
*****************************************************/
function getMachineResource($mysql_link){
- $machine_query = mysql_query("SELECT * FROM machine ORDER BY nickname ASC") or die (mysql_error());
- return $machine_query;
+ $machine_query = mysql_query("SELECT * FROM machine ORDER BY nickname ASC") or die (mysql_error());
+ return $machine_query;
}
/*****************************************************
@@ -48,19 +48,19 @@
*
*****************************************************/
function getRecentMachineResource($mysql_link){
- $night_query = mysql_query("SELECT machine FROM night where DATE_SUB(NOW(), INTERVAL 1 MONTH) <= added") or die (mysql_error());
- $machines="where id=0";
- $machine_arr = array();
- while($row = mysql_fetch_array($night_query)){
- if(!isset($machine_arr["{$row['machine']}"])){
- $machine_arr["{$row['machine']}"]=1;
- $machines.=" or id={$row['machine']}";
- }
- }
- mysql_free_result($night_query);
- $machine_query = mysql_query("SELECT * FROM machine $machines ORDER BY nickname ASC") or die (mysql_error());
+ $night_query = mysql_query("SELECT machine FROM night where DATE_SUB(NOW(), INTERVAL 1 MONTH) <= added") or die (mysql_error());
+ $machines="where id=0";
+ $machine_arr = array();
+ while($row = mysql_fetch_array($night_query)){
+ if(!isset($machine_arr["{$row['machine']}"])){
+ $machine_arr["{$row['machine']}"]=1;
+ $machines.=" or id={$row['machine']}";
+ }
+ }
+ mysql_free_result($night_query);
+ $machine_query = mysql_query("SELECT * FROM machine $machines ORDER BY nickname ASC") or die (mysql_error());
- return $machine_query;
+ return $machine_query;
}
/*****************************************************
@@ -72,19 +72,19 @@
*
*****************************************************/
function getOldMachineResource($mysql_link){
- $night_query = mysql_query("SELECT machine FROM night where DATE_SUB(NOW(), INTERVAL 1 MONTH) > added") or die (mysql_error());
- $machines="where id=0";
- $machine_arr = array();
- while($row = mysql_fetch_array($night_query)){
- if(!isset($machine_arr["{$row['machine']}"])){
- $machine_arr["{$row['machine']}"]=1;
- $machines.=" or id={$row['machine']}";
- }
- }
- mysql_free_result($night_query);
- $machine_query = mysql_query("SELECT * FROM machine $machines ORDER BY nickname ASC") or die (mysql_error());
+ $night_query = mysql_query("SELECT machine FROM night where DATE_SUB(NOW(), INTERVAL 1 MONTH) > added") or die (mysql_error());
+ $machines="where id=0";
+ $machine_arr = array();
+ while($row = mysql_fetch_array($night_query)){
+ if(!isset($machine_arr["{$row['machine']}"])){
+ $machine_arr["{$row['machine']}"]=1;
+ $machines.=" or id={$row['machine']}";
+ }
+ }
+ mysql_free_result($night_query);
+ $machine_query = mysql_query("SELECT * FROM machine $machines ORDER BY nickname ASC") or die (mysql_error());
- return $machine_query;
+ return $machine_query;
}
/*****************************************************
@@ -95,11 +95,11 @@
*
*****************************************************/
function getNightInfo($night_id, $mysql_link){
- $query="SELECT * FROM night WHERE id=$night_id";
- $today_query = mysql_query("SELECT * FROM night WHERE id=$night_id") or die ("$query failed! " . mysql_error());
- $today_row = mysql_fetch_array($today_query);
- mysql_free_result($today_query);
- return $today_row;
+ $query="SELECT * FROM night WHERE id=$night_id";
+ $today_query = mysql_query("SELECT * FROM night WHERE id=$night_id") or die ("$query failed! " . mysql_error());
+ $today_row = mysql_fetch_array($today_query);
+ mysql_free_result($today_query);
+ return $today_row;
}
/*****************************************************
@@ -110,8 +110,8 @@
*
*****************************************************/
function getNightsResource($machine_id, $mysql_link, $start="2000-01-01 01:01:01", $end="2020-12-30 01:01:01", $order="DESC"){
- $query = mysql_query("SELECT * FROM night WHERE machine=$machine_id and added<=\"$end\" and added>=\"$start\" order by added $order") or die (mysql_error());
- return $query;
+ $query = mysql_query("SELECT * FROM night WHERE machine=$machine_id and added<=\"$end\" and added>=\"$start\" order by added $order") or die (mysql_error());
+ return $query;
}
/*****************************************************
@@ -121,8 +121,8 @@
*
*****************************************************/
function getRecentTests($hours="24", $mysql_link){
- $result = mysql_query("select * from night where DATE_SUB(NOW(),INTERVAL $hours HOUR)<=added ORDER BY added DESC") or die (mysql_error());
- return $result;
+ $result = mysql_query("select * from night where DATE_SUB(NOW(),INTERVAL $hours HOUR)<=added ORDER BY added DESC") or die (mysql_error());
+ return $result;
}
/*****************************************************
@@ -133,32 +133,35 @@
*
*****************************************************/
function calculateDate($mysql_link, $time_frame="1 YEAR", $origin_date="CURDATE()"){
- if(strpos($origin_date, "CURDATE")===false){
- $query=mysql_query("SELECT \"$origin_date\" - INTERVAL $time_frame") or die(mysql_error());
- }
- else{
- $query=mysql_query("SELECT $origin_date - INTERVAL $time_frame") or die(mysql_error());
- }
- $row = mysql_fetch_array($query);
- mysql_free_result($query);
- $time = $row[0];
- return $time;
+ if(strpos($origin_date, "CURDATE")===false){
+ $query=mysql_query("SELECT \"$origin_date\" - INTERVAL $time_frame") or die(mysql_error());
+ }
+ else{
+ $query=mysql_query("SELECT $origin_date - INTERVAL $time_frame") or die(mysql_error());
+ }
+ $row = mysql_fetch_array($query);
+ mysql_free_result($query);
+ $time = $row[0];
+ return $time;
}
/*****************************************************
*
- * Purpose: get file size for a specific file
- * Returns: An array with the first element being the
- * name of the file, then the file size, then night id,
- * then build type.
- *
- *****************************************************/
-function get_file($mysql_link, $file, $night_id){
- $query = mysql_query("select * from file WHERE file=\"$file\" and night=$night_id") or die (mysql_error());
- $file = mysql_fetch_array($query);
- $result = array("{$file['file']}","{$file['size']}","{$file['night']}","{$file['type']}");
- mysql_free_result($query);
- return $result;
+ * Purpose: get every file size reported on a specific
+ * dat=y
+ * Returns: An array with the key being the name of the
+ * file and the value being the size of the file.
+ *
+ *****************************************************/
+function getAllFileSizes($mysql_link, $night_id){
+ $select = "select * from file WHERE night=$night_id";
+ $query = mysql_query($select) or die (mysql_error());
+ $result=array();
+ while($file = mysql_fetch_array($query)){
+ $result["{$file['file']}"]=$file['size'];
+ }
+ mysql_free_result($query);
+ return $result;
}
/*****************************************************
@@ -171,30 +174,103 @@
*
*****************************************************/
function get_file_history($mysql_link, $machine_id, $file_name){
- $nights_select = "select id, added from night WHERE machine=$machine_id ".
- "order by added desc";
- $nights_query = mysql_query($nights_select)
- or die (mysql_error());
- $result = array();
- while($row = mysql_fetch_array($nights_query)){
- $file_select = "select * from file where night={$row['id']} and ".
- "file=\"$file_name\"";
- $file_query = mysql_query($file_select);
- $file_array = mysql_fetch_array($file_query);
- if(isset($file_array['file'])){
- $result["{$row['added']}"]=array("{$file_array['file']}",
+ $nights_select = "select id, added from night WHERE machine=$machine_id ".
+ "order by added desc";
+ $nights_query = mysql_query($nights_select)
+ or die (mysql_error());
+ $result = array();
+ while($row = mysql_fetch_array($nights_query)){
+ $file_select = "select * from file where night={$row['id']} and ".
+ "file=\"$file_name\"";
+ $file_query = mysql_query($file_select);
+ $file_array = mysql_fetch_array($file_query);
+ if(isset($file_array['file'])){
+ $result["{$row['added']}"]=array("{$file_array['file']}",
"{$file_array['size']}",
"{$file_array['type']}");
- }//end if
- else {
- $result["{$row['added']}"]=array("-",
- "-",
- "-");
- }
- mysql_free_result($file_query);
- }//end while
- mysql_free_result($nights_query);
- return $result;
+ }//end if
+ else {
+ $result["{$row['added']}"]=array("-",
+ "-",
+ "-");
+ }
+ mysql_free_result($file_query);
+ }//end while
+ mysql_free_result($nights_query);
+ return $result;
+}
+
+/*****************************************************
+ *
+ * Purpose: build a comparison table for file size changes
+ * Returns: An array with the key being the name of the
+ * file and the value being an array with the following
+ * data: [0]size of file for specified test [1] % change
+ * in file size from previous test [2] % change in file size
+ * from a test >5 tests ago. If for any reason data is not
+ * not available the array will contain -.
+ *
+ *****************************************************/
+function buildFileSizeTable($mysql_link, $machine_id, $night_id){
+ $result=array();
+
+ //setting up the night ids
+ $select = "select id from night WHERE id<$night_id and machine=$machine_id order by added desc";
+ $query = mysql_query($select) or die (mysql_error());
+ $row=mysql_fetch_array($query);
+
+ $cur_night=$night_id;
+ $prev_night=$row['id'];
+ for($x=0; $x<4 && $row=mysql_fetch_array($query); $x++){}
+ $old_night=$row['id'];
+ mysql_free_result($query);
+
+
+ if($cur_night>0) { $cur_data=getAllFileSizes($mysql_link, $cur_night); }
+ if($prev_night>0) { $prev_data=getAllFileSizes($mysql_link, $prev_night); }
+ if($old_night>0) { $old_data=getAllFileSizes($mysql_link, $old_night); }
+
+ $cur_sum=0;
+ $prev_sum=0;
+ $old_sum=0;
+
+#$delta = round($today_results["$x"][$y] - $yesterday_results["$x"][$y],2);
+
+ foreach (array_keys($cur_data) as $file){
+ $cur_sum+=$cur_data["$file"];
+
+ if(isset($prev_night["$file"]) && isset($cur_night["$file"])) {
+ $prev_diff = (($cur_data["$file"] - $prev_data["$file"]) / $prev_data["$file"] ) * 100;
+ $prev_sum+=$prev_data["$file"];
+ } else {
+ $prev_diff="-";
+ }
+
+ if(isset($old_night["$file"]) && isset($cur_data["$file"])){
+ $old_diff = (($cur_data["$file"] - $old_data["$file"]) / $old_data["$file"] ) * 100;
+ $old_sum+=$old_data["$file"];
+ } else {
+ $old_diff = "-";
+ }
+ $result["$file"]=array($cur_data["$file"], round($prev_diff,2), round($old_diff,2));
+ }
+
+
+ if($old_sum>0){
+ $old_diff = (($cur_sum - $old_sum) / $old_sum ) * 100;
+ } else{
+ $old_diff="-";
+ }
+
+ if($prev_sum>0){
+ $prev_diff = (($cur_sum - $prev_sum) / $prev_sum ) * 100;
+ } else{
+ $prev_diff="-";
+ }
+
+ $result["Total Sum"] = array($cur_sum, round($prev_diff,2), round($old_diff,2));
+
+ return $result;
}
/*****************************************************
@@ -211,20 +287,20 @@
$files = get_file_history($mysql_link, $machine_id, $file);
foreach (array_keys($files) as $f){
- print "$f = > {$files["$f"][0]}<br>\n";
+ print "$f = > {$files["$f"][0]}<br>\n";
}
$machine_info = getMachineInfo(21, $mysql_link);
foreach (array_keys($machine_info) as $key){
- print "$key => {$machine_info["$key"]}<br>\n";
+ print "$key => {$machine_info["$key"]}<br>\n";
}
print "<br><br><br>\n";
$night_id=-1;
$night_resource = getNightsResource($machine_info['id'], $mysql_link);
- while($row = mysql_fetch_array($night_resource)){
- print "added => {$row['added']}<br>\n";
- $night_id=$row['id'];
+ while($row = mysql_fetch_array($night_resource)){
+ print "added => {$row['added']}<br>\n";
+ $night_id=$row['id'];
}
mysql_free_result($night_resource);
print "<br><br><br>\n";
@@ -235,9 +311,9 @@
print "<br><br><br>\n";
$recent_resource = getRecentTests($machine_info['id'], $mysql_link);
- while($row = mysql_fetch_array($recent_resource)){
- print "added => {$row['added']}<br>\n";
- $night_id=$row['id'];
+ while($row = mysql_fetch_array($recent_resource)){
+ print "added => {$row['added']}<br>\n";
+ $night_id=$row['id'];
}
mysql_free_result($recent_resource);
print "<br><br><br>\n";
More information about the llvm-commits
mailing list